DEV Community

Discussion on: Where Javascript Coercion went wrong?

Collapse
 
somedood profile image
Basti Ortiz

console.log(1 < 4 < 3); it will return true instead of false because the javascript sees it as:
console.log(true < 3);
“true” would be coerced to 1 and when compared will be 1 < 3 which will be true.

I never knew that. I had always thought it was just a quirk of JavaScript. Thanks for clearing things up!

Collapse
 
aloksdiptim profile image
alokz diptim!

Yes, it is because of coercion.

Thanks for reading the post.