Javascript 中 null 与 undefined关系
下面结果是什么?
<html>
<head>
<script type="text/javascript">
function a()
{
//没有返回值
}
alert(a());
</script>
</head>
<body>
</body>
</html>
结果: undefined
所以函数没有声明返回值,就反悔 undefined作为返回值。
null 与 undefined 的关系: undefined实际是从null派生出来的。
验证:
<html>
<head>
<script type="text/javascript">
alert(null == undefined);
</script>
</head>
<body>
</body>
</html>
结果是: true
浙公网安备 33010602011771号