jeudi 1 septembre 2016

Get an element's complete index in an object

Say I have an object obj and an element that I can access with obj["a"]["b"]["c"]. I need a function that does something like this:

getKeys(obj["a"]["b"]["c"]);
// returns ["a", "b", "c"]

Alternatively, I'd like to be able to cycle through the object's properties and at each iteration have access to each property's complete index (e.g. "a", "b" and "c").

How can I do this?





Aucun commentaire:

Enregistrer un commentaire