var num;
console.log(typeof num) //返回的是underfined
console.log(typeof test) //返回的是underfined
总结:只定义变量名没有赋值,或者没有定义变量 检测类型都是返回underfined。但是如果直接使用未定义的变量会控制台会报错
函数参数或无返回值是为undefined
function hd(web) {
console.log(web); //没有值所以undefined
return web;
}
console.log(hd()); //没有传值所以为underfined
var num=null
console.log(typeof num) //返回的是null
总结:只有赋值为null的时候返回的才是null
网友评论