What is the difference between != null and !== null?

This question already has an answer here:

  • Difference between == and === in JavaScript [duplicate] 2 answers

  • The answer to the specific question about whether there's ever a case where != and !== comparisons involving null get different answers is yes :

    undefined != null  // false
    undefined !== null // true
    

    The rules for == and != explicitly include a clause that stipulates that null and undefined are the same.

    Personally — that is, in my code — that fact is a reason for using != (or == ) when checking for null in cases where undefined should be treated the same way (which is a pretty common situation).

    链接地址: http://www.djcxy.com/p/19428.html

    上一篇: 我应该使用==还是===在Javascript中?

    下一篇: != null和!== null之间有什么区别?