Search code examples
javascriptfrontendecmascript-5

in javascript,why null !== undefined is true,but null == undefined also is true?


console.log(undefined !== null);//true
console.log(undefined == null);//true

I can't undestand why undefined !==null,but i know undefined == null,because The language specification explicitly says:

If x is null and y is undefined, return true


Solution

  • You're using strict equality for the first comparison and non-strict for the latter. You'll find that undefined === null is false as expected.