夫特3:
我有兩個陣列,一個是字典(JSON)的陣列,並且另一個是索引路徑索引(int值)的(集合類型索引與元素行&部分)。藉助第二個數組的索引行,我需要從第一個數組中刪除元素。
夫特3陣列 - 刪除的多個元素與其它陣列的幫助
var arrayString = [ // Array with Json elements
{ "name" : "A" },
{ "name" : "B" },
{ "name" : "C" },
{ "name" : "D" },
{ "name" : "E" },
{ "name" : "F" },
{ "name" : "G" },
{ "name" : "H" }
]
現在第二個數組(從第一個數組中刪除)
var arrayIndex = [ 2, 3, 5 ] // Array with
我怎樣才能做到這一點? 我想結果數組一樣
var arrayString = [
{ "name" : "A" },
{ "name" : "D" },
{ "name" : "F" },
{ "name" : "G" },
{ "name" : "H" }
]
從數組中移除元素會影響之後的元素的索引,你應該確保指數刪除陣列中的降序排列 – Paulw11
@ Paulw11完全忘記了排序, thanx的建議。 –