Comparison JS: Abstract Equality Comparison

Viewed 24

I have this example:

console.log("0"== 0)

Comparing the following documentation

Abstract Equality Comparison

and looking at point 6, which corresponds to my case, that is

If Type(x) is String and Type(y) is Number, return the result of the comparison !ToNumber(x) == y.

I get that:

ToNumber("0") is 0, so !ToNumber("0") is 1, so I get 1 == 0, meaning I should get false.

Why is true on the console? Comparing the documentation I should get false.

0 Answers
Related