【发布时间】:2010-01-19 04:46:33
【问题描述】:
为什么会这样(返回“一、二、三”):
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>');
我必须对我的“参数”变量执行什么操作才能在其上使用 .join()?
【问题讨论】:
-
我已经修改了我的答案,以考虑到您更新的问题 - 具体来说,“我必须做什么才能完成这项工作?”部分。
标签: javascript jquery join