So let's say I have a JSON called foo:
{
"key" : "value",
"one" : "two"
}
I want to delete the first element, so with the index of 0. But I don't know that it's key
.
I tried using delete foo[0]
but it didn't work. It outputs true
but it doesn't actually delete it.
Is there a way to do this without looping through it?
Get the key with Object.keys(JSON)[0]
and then remove it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With