typeof //用来检查对象的类型 typeof v //undefined typeof null //object var a = {} var b = [] a instanceof Array //false b instanceof Array //true
if (!undefined){ console.log('undefined is false') } // undefined false if (!null){ console.log(' null is false') } // null false null == undefined //true Number(null) //0 5 + null // 5 + 0 Number(undefined) //NaN 5 + undefined //NaN /* null 代表的是一个空的对象,转为数值为0。undefined 此处表示的是一个无定义的原始值,转为数值为NaN。 */
|
|