因为对javascript中的null和undefined有些分不清楚,因此在试验之后进行一下小结。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title></title>
<script type="text/javascript" charset="utf-8">
var a;
var b = null;
var c = {};
console.log(x); //报错
console.log(a); //undefined
console.log(b); //null
console.log(c.somevalue); //undefined
console.log(!a, !b); //true true
</script>
</head>
<body>
</body>
</html>
what is the difference between null and undefined in JavaScript? - Stack Overflow
原文地址:http://blog.csdn.net/timberwolf_2012/article/details/45701245