javascript的Undefined,null区别

 

//在javascript中null表示“什么都没有” ,是一个特殊的类型,表示一个空对象引用;    var person = null;    //值为null(空),但类型为对象    console.log(person);   //null    console.log(typeof  person);   //object//在javascript中, undefined是一个没有设置值的变量    var person = undefined;   //值为undefined,类型为undefined    console.log(undefined);    console.log(typeof  person);  //undefined
相关文章
相关标签/搜索