Js weirdness Memes

Posts tagged with Js weirdness

JS Is A Very Respectable Language

JS Is A Very Respectable Language
JavaScript really said "consistency is for COWARDS" and honestly? It committed to the bit. ๐Ÿ’€ So you've got an array [1, 2, 3] and you're like "hey what's at index -2?" JavaScript casually returns undefined because negative indices don't exist in JS arrays... EXCEPT when you use .at(-2) which is specifically designed to handle negative indices and suddenly it's like "oh you want the second element from the end? Here's your 2, bestie!" Then you assign foo[-2] = 4 which JavaScript happily accepts because arrays are objects and you just created a STRING property called "-2" on that array object. So now foo[-2] returns 4 from the object property while foo.at(-2) STILL returns 2 from the actual array position. Same syntax, completely different universes. Very respectable. Very normal. Nothing to see here. ๐ŸŽช

JavaScript NaN Is Weird

JavaScript NaN Is Weird
JavaScript's equality comparison is like that one friend who can't decide what they want for dinner. The console shows NaN === NaN returning false because in JS, each NaN is its own special snowflake. Two identical-looking "not a number" values? Nope, completely different according to JavaScript! The corporate "spot the difference" meme perfectly captures the absurdity - there's literally no difference between the two NaN cards, yet JavaScript insists they're not the same. It's the programming equivalent of gaslighting. Next time someone asks why developers drink, just show them this.

Well Which Is It

Well Which Is It
JavaScript: "NaN stands for 'Not A Number'" Also JavaScript: typeof NaN returns 'number' This is peak JavaScript energy right here. The language literally created a special value to tell you something isn't a number, then categorized it as a number. It's like labeling a vegetarian dish "Contains No Meat" and listing the first ingredient as beef. Just another day in JS wonderland where nothing makes sense and we're all pretending it's fine.