mercredi 18 février 2015

deep nested object reference


this is my second try, I deleted previous one because of wrong question asking and not getting desired answers


I need to create reference/shortcut for deeply nested object (unknown depth).

Example would be chrome bookmarks

If I need to change bookmark title (let's say 5 times per second), I would like to find that object by ID once, and on that path create reference for any further update so I don't have to do recursive loops through all nested arrays searching for bookmark ID. That reference (shortcut) must be live one.

I was thinking something like this (from image example):



Object[0].children[1].children[2].children[4].children[6].title = 'trololo';


...but I can't create string and use eval to concatenate that path. Is there any other way to reference that object? I can get parent indexes easily or anything else.





Aucun commentaire:

Enregistrer un commentaire