Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best practice for setting value of nested objects? #72

Open
bcamp1973 opened this issue Jan 7, 2014 · 1 comment
Open

Best practice for setting value of nested objects? #72

bcamp1973 opened this issue Jan 7, 2014 · 1 comment

Comments

@bcamp1973
Copy link

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';
@doublejosh
Copy link

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants