我正在尋找解決方案,將數組項目推入/轉換回對象,而不使用鍵?將嵌套數組轉換爲對象
function pleaseBuy(){
var args = arguments;
for(var i = 0; i < arguments[0].length; ++i) {
args += args[i];
};
};
function getList(){
return ["pepsi","cola","7up"];
}
var list = ({ favorite: "drpepper"}, getList())
pleaseBuy(list)
預期結果:
args = ({ favorite: "drpepper"}, "pepsi", "cola", "7up")