console.log(a)//报错 Uncaught ReferenceError: conaole is not defined(…)
var a;console.log(a)//不报错 输出undefined
区别:
undefined var a;只定义,没有赋值
null 不存在
"" var a="";浏览器中a赋值为“”
console.log(a)//报错 Uncaught ReferenceError: conaole is not defined(…)
var a;console.log(a)//不报错 输出undefined
区别:
undefined var a;只定义,没有赋值
null 不存在
"" var a="";浏览器中a赋值为“”
typeof 是运算符,注意不是函数,是运算符,其作用,是考察变量究竟是什么类型 alert(
控制台说话:
JavaScript|null和undefinednull表示什么也没有,这个可以和C++中的指针为空一起理解,是一个只有一个值的特殊类型,
js
null 和 undefined
Javascript undefined 和 null 虽然 Javascript 一切皆对象,但是类型还是有区别的。 undefined 表示 未定义的数据类型。 null 表示空对象。 在判断时没有区分。
JavaScript null vs undefined1. null 变量已声明,但给变量分配空值;
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M