Codog

关注微信公众号:Codog代码狗

0%

undefined和null的区别

  • null是有值,但值是空。undefined是值未定义。
  • typeof null === 'object', typeof undefined === 'undefined
  • JSON.stringify会忽略undefined值,但会保留null值;
  • 他们都是falsy ,不加!比较,永远是false (Boolean(undefined) ->// false, Boolean(null) ->// false);