我有一个这样的数组:
"output" : [
{
"zip":35004,
"state":"AL",
"City":"Acmar",
"lat":33.584132,
"lng":-86.51557
},
{
"zip":35005,
"state":"AL",
"City":"Adamsville",
"lat":33.588437,
"lng":-86.959727
}
]
现在我如何删除' lat'而且' long'来自所有子阵列。我想要一个像这样的输出:
"output" : [
{
"zip":35004,
"state":"AL",
"City":"Acmar"
},
{
"zip":35005,
"state":"AL",
"City":"Adamsville"
}
]
最快的方法是什么?
答案 0 :(得分:4)
我想
for (var i = 0; i < row.length; i++) {
delete row[i].lat;
delete row[i].long;
}
For比forEach更快,使用delete显然是