DEV Community

loading...

Discussion on: JavaScript == vs ===, Which one you should use?

Collapse
wheatup profile image
Hao

Have to mention Object.is:

console.log(0 == '0');              // true
console.log(0 === '0');             // false
console.log(Object.is(0, '0'));     // false

console.log(NaN == NaN);            // false
console.log(NaN === NaN);           // false
console.log(Object.is(NaN, NaN));   // true

console.log(+0 == -0);              // true
console.log(+0 === -0);             // true
console.log(Object.is(+0, -0));     // false
Forem Open with the Forem app