Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
YouAreAPIRate4670360dYes, but in most cases it does string conversion. Because of this you get unforgettable moments like 2 == [[[[]]]] -> true
Eventyret455360dAlso would it not be correct thay booleans are 0 and 1? False and true?
So your saying is 1 ==2? False? It's funny because it's
hashedram9239360d2 is truthy. It's true that 2 exists. That's what Boolean(2) means.
But it isn't equal to the value true.
It's called type casting and it's how js is supposed to work. Understand and embrace the flexibility.
hashedram9239360d@johnSnow That's because of a genuinely fucking stupid concept called type coercion that js tends to do. It's one of the bad parts that even Crockford acknowledges.
== Just ignores type right out. But Boolean(x) kind of does some fucky nudging.
If you search for js type coercion, you'll get many other retarded examples, most worse than this.
No excuses for this one. Still one can learn to avoid coercion most of the time.
jespersh6672343dThis is why we do stuff like:
Your Job Suck?
Take a quick quiz from Triplebyte to skip the job search hassles and jump to final interviews at hot tech firms
Get a Better Job