js 基础

typeof  //用来检查对象的类型
typeof  v   //undefined

typeof null   //object


var a = {}
var b = []

a instanceof Array  //false
b instanceof Array  //true


null 与 undefined 区别
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。
*/

 

 
posted @ 2021-03-08 14:12  not1ng  阅读(27)  评论(0)    收藏  举报