一、 前言
因为对JavaScript中的 null\undefined\” 有些分不清楚,因此在试验之后进行一下小结。
二、 源码
console.log(x); //报错
console.log(a); //undefined
console.log(b); //null
console.log(c.somevalue); //undefined
console.log(d); //
console.log(!a, !b, !d); //true true true
</script>
</head>
<body>
</body>
</html>
三、 总结
1.未定义变量: 使用会报错
2.声明变量未赋值: 变量为undefined
3.声明变量并赋值为null: 变量为null
4.对象中未声明的变量:变量为undefined
5.空字符串:变量为”
6.null\undefined\” 的非: 均为true