-2
我正在从javascript数组中删除。删除数组后重新排序。从Javascript阵列重新排序
Array [ Object, Object, Object, Object, Object, Object ];
0 Object
d:17065
1 Object
d:17156
2 Object
d:17246
3 Object
d:17065
4 Object
d:17156
5 Object
d:17338
for(d = 0; d < delete_array.length; d++)
{
data_array[0].splice(delete_array[d],1);
}
经过上述删除。数组更改为。
Array [ Object, Object, Object ];
0 Object
d:17156
1 Object
d:17065
2 Object
d:17246
3 Object
如何防止这种情况发生?
使用'data_array中[0] = data_array中[0] .filter(X =>!delete_array.includes(X))' – Rajesh
是真不明白什么是您预期的输出中。你能提供你想要的输出吗? – rakwaht
'splice'将索引作为第一个参数。 – ASDFGerte