jStorage
jStorage copied to clipboard
Best practice for setting value of nested objects?
trafficstars
our data is nested a few layers deep. i've been using the following approach to save changes to nested values, but it feels sloppy. is there a better way?
$.jStorage.get('data')['authors'][33]['books'][5]['title'] = 'See Spot Run';
That code would not save the value, just copy it with an updated deep value.
To save you would need to...
var data = $.jStorage.get('data');
data.authors[33].books[5].title = 'See Spot Run';
$.jStorage.set('data', data);