根据索引将一行元素插入多维数组
例如:
MultiArray = new Array(5);
MultiArray [0] = new Array(2);
MultiArray [0][0] = "Tom";
MultiArray [0][1] = "scientist";
MultiArray [1] = new Array(3);
MultiArray [1][0] = "Beryl";
MultiArray [1][1] = "engineer";
MultiArray [1][2] = "Doctor";
MultiArray [2] = new Array(2);
MultiArray [2][0] = "Ann";
MultiArray [2][1] = "surgeon";
MultiArray [3] = new Array(2);
MultiArray [3][0] = "Bill";
MultiArray [3][1] = "taxman";
MultiArray [4] = new Array(2);
MultiArray [4][0] = "Myrtal";
MultiArray [4][1] = "bank robber";
MultiArray.splice(1,0, new Array(2){"two","one"});
我的代码中的最后一行不起作用。我不确定其余的代码是否正确。
现在谁能告诉我是否可以在中间的某处插入一行元素并将剩余的元素向下移动一个索引?