I have an associative array stored in another associative array. I know how to splice a specific value in just a regular array as such:
arr.splice(arr.indexOf('specific'), 1);
I was wondering how one could splice an array such as this:
arr['hello']['world']
EDIT Would this shorten hello['world']['continent']
var hello = {};
hello['world'] = {};
hello['world']['continent'] = "country";
delete hello['world']['continent'];
alert(hello['world']['continent'])
You should be able to just just use the delete keyword.
How do I remove objects from a javascript associative array?
Edit, based on other comments:
For the sake of readability, you can also do:
Since we are really just talking about objects, and not traditional arrays, there is no array length. You can however delete a key from an object.