为什么这项工作(返回 “一,二,三”):为什么.join()不能使用函数参数?
var words = ['one', 'two', 'three'];
$("#main").append('<p>' + words.join(", ") + '</p>');
这项工作(返回 “名单:111”):
var displayIt = function() {
return 'the list: ' + arguments[0];
}
$("#main").append('<p>' + displayIt('111', '222', '333') + '</p>');
,但不是这个(返回空白):
var displayIt = function() {
return 'the list: ' + arguments.join(",");
}
$("#main").append('<p>' + displayIt('111', '222', '333') + '</p>');
我有什么做的,我的“论据”的变量设置为使用就可以了。加入()?
参见:http://stackoverflow.com/questions/1424710/why-is-my-join-on-a-javascript- array-failing – Shog9 2010-01-19 04:56:24
我已经修改了我的答案,以考虑您更新的问题 - 具体来说,“我必须做些什么来完成此项工作?”部分。 – 2010-01-19 04:58:34