<!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>
1 回答

弑天下
TA贡献1818条经验 获得超8个赞
写代码写规范好吧. 根据 javascript权威指南这本书, 所以return
直接成为一个语句,返回undefined
.
参考书籍中最后一张图片最后的红色部分.
添加回答
举报
0/150
提交
取消