Reputation: 433
I have an array like this:
"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
}
]
Now how do I remove 'lat' and 'long' from all the sub-arrays. I want an output like this:
"output" : [
{
"zip":35004,
"state":"AL",
"City":"Acmar"
},
{
"zip":35005,
"state":"AL",
"City":"Adamsville"
}
]
What is the fastest possible way to do this?
Upvotes: 0
Views: 47
Reputation: 2767
I guess
for (var i = 0; i < row.length; i++) {
delete row[i].lat;
delete row[i].long;
}
For is faster than forEach and using delete is obviously
Upvotes: 4