【发布时间】:2014-05-22 16:42:12
【问题描述】:
“foo”下面的函数不起作用。我想要一种方法来获得如下所示的输出,围绕“foo”中显示的原理工作。
function foo() {
var i;
i = "hello world";
i.a = "hello kitten";
i.b = "hello... Is there anybody out there?"
return i; // This doesn't work
}
这就是我想要的:
alert(foo()); // "hello world"
var bar = foo();
alert(bar.a); // "hello kitten"
alert(bar.b); // "hello... Is there anybody out there?"
谢谢。
【问题讨论】:
标签: javascript object return return-value