Created
November 3, 2016 23:32
-
-
Save nrojas13/68b79e21d0c81aa22ad762c9a4db38d0 to your computer and use it in GitHub Desktop.
How to store an array in localstorage js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Store an array in local storage | |
// The array to store | |
var array = [1, 2, 3]; | |
// Store after JSON stringifying (is this a verb?) it | |
localStorage.setItem('myArray', JSON.stringify(array)); | |
// Get an array from local storage | |
// Retrieve the array from local storage | |
var array = localStorage.getItem('myArray'); | |
// Parse it to something usable in js | |
array = JSON.parse(array); |
and how to rewrite?
nice solution
Thanks a lot bro for this solution
nice solution
Thank you so much!
Best solution
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!