<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
function foo1()
{
return{
bar: "hello1"
};
}
function foo2()
{
return
{
bar2: "hello2"
};
}
var a=foo1();
var b=foo2();
alert(a);
alert(b);
//为何第一次出来object object 第二次undefined
</script>
</body>
</html>
写代码写规范好吧. 根据 javascript权威指南这本书, 所以
return
直接成为一个语句,返回undefined
.参考书籍中最后一张图片最后的红色部分.