0

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

owen-yu
  • 25
  • 3

1 Answers1

1

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.

Marty
  • 39,033
  • 19
  • 93
  • 162
  • 1
    And similarly, with non-strict `!=` checking, `undefined != null` gets `false`. At least in this case, it's consistent, non-strict says they're equal (so `!=` gets `false`, `==` gets `true`), while strict says they're not equal (so `!==` gets `true` and `===` gets `false`). – ShadowRanger Jun 22 '17 at 01:40
  • @Marty thanks,i got it – owen-yu Jun 22 '17 at 01:46