var a = new Array();
var b = new Array();
var c = [a,b];
var str = 'hello,world,nice,day';
for(var i = 0; i < c.length; i++){
c[i] = str.split(',');
}
执行后我想要:
c = [a, b];
a = ['hello', 'world', 'nice', 'day'];
b = ['hello', 'world', 'nice', 'day'];
但我真的有:
c = [['hello', 'world', 'nice', 'day'], ['hello', 'world', 'nice', 'day']];
a = [];
b = [];
我能修好吗?
更新: 雷诺斯的决定真是太好了。谢谢。
最佳答案
for(var i = 0; i < c.length; i++){
c[i].push.apply(c[i], str.split(','));
}
关于php - JavaScript - 赋值 - 数组的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8014584/