I recently found out that javascript’s .sort() function, when called without arguments on an array of numbers, converts them all to strings and sorts them alphabetically 🤡
Javascript lets you compare unlike types without extra steps using ==. If you want strict comparison where “2” isn’t 2, use === and !==. Personally, I find that easier than having to parseint or cast every damn thing or whatever c does (strtol?). That said, I have build tools set up to enforce strict comparison because I don’t trust myself or others.
I recently found out that javascript’s .sort() function, when called without arguments on an array of numbers, converts them all to strings and sorts them alphabetically 🤡
I’m a C programmer. My first time writing Javascript and ran into some sort of bug involving a === sign or something. Javascript is a silly language.
Javascript lets you compare unlike types without extra steps using ==. If you want strict comparison where “2” isn’t 2, use === and !==. Personally, I find that easier than having to parseint or cast every damn thing or whatever c does (strtol?). That said, I have build tools set up to enforce strict comparison because I don’t trust myself or others.
Truish and falsish and nullish are all concepts made up by madmen. JavaScript is the language of the damned.
If one is alphabetising things, which cones first “A” or “AA”?