2
我想合併使用索引的2個JavaScript數組。JavaScript數組合並使用索引
讓我們說我有陣A
與
A[0] = 1;
A[1] = 9;
...
A[5] = 12;
和數組B
有:
B[0 ... 5] = garbage, unused;
B[6] = 23;
B[7] = 99;
B[8] = 31;
...
B[10] = 990;
我想與B
合併A
做:
merged[0] = 1;
merged[1] = 9;
..
merged[5] = 12;
merged[6] = 23;
...
merged[10] = 999;
豈今做完了?
+1不錯的解決方案。 –
@Felix:謝謝! –