【发布时间】:2016-08-30 22:57:05
【问题描述】:
我在 java 脚本中有两个返回类型相同的函数,但返回类型不同。下面截图id的使用代码
function foo1()
{
return {
bar: "hello"
};
}
function foo2()
{
return
{
bar: "hello"
};
}
调用函数..
console.log("foo1 returns:");
console.log(foo1());
console.log("foo2 returns:");
console.log(foo2());
输出结果 ....
foo1 returns:
Object {bar: "hello"}
foo2 returns:
undefined
【问题讨论】:
-
你能提供完整的代码而不是一小部分吗?
-
@Darshit 这是完整的代码。
-
@Konst 请不要建议对代码进行这样的编辑,除非您完全了解所有后果 - 您所做的更改会导致问题消失。
-
是的@JamesThorpe 可能是关于 ASI 的问题。这可以帮助你stackoverflow.com/questions/2846283/…
标签: javascript console console.log