【发布时间】:2019-08-14 17:36:55
【问题描述】:
我声明一个这样的 JSON
var json{
section1: [],
section2: [],
section3: []
}
我想删除这种方式的特定项目或类似的东西
json[section][index].remove();
我试过这种方式
delete json[section][index];
但是当我这样做时,数组元素不会重新排列
【问题讨论】:
-
您可以使用
splice()从数组中删除一个项目。 --> stackoverflow.com/questions/5767325/… -
如果你只是想删除一个基于名为
index的特定属性,你可以这样做delete json["section"+index]
标签: javascript jquery arrays json