re: Why I use JS. VIEW POST


Nice, It's a good post. I also like very much JS.

Just a note. On the point 3. Types and Equality you said...

However, if I know that 123 is a string, and I want to check equality, I can just use strict equality if I want. (===)

But actually is not exactly that way

The difference between == and === is usually characterized that == checks for value equality and === checks for both value and type equality. However, this is inaccurate. The proper way to characterize them is that == checks for value equality with coercion allowed, and === checks for value equality without allowing coercion; === is often called "strict equality" for this reason.

Source => You-Dont-Know-JS (BTW this is maybe the best book out there to learn JS I really recommend it.

So when you use '==' you are allowing coercion. So if the types are not the same. The interpreter will follow a very specific set of rules to change the types of the values. This rules are defined in chapter 11.9.3 of the ecma specification => ecma-international.org/ecma-262/5.1/


Yeah, I meant to make the same point in the article. Maybe it was misunderstandable? Maybe I’ll change it. Thanks!

code of conduct - report abuse