Skip to content Skip to sidebar Skip to footer

How To Store Array In Localstorage?

I have to store an array in window.localStorage. How would I store the array in window.localStorage using console window? EX: cards: Array[0] length: 0 I have to store this. Now h

Solution 1:

localStorage only support string so you'll have to parse it to JSON

var arr = ["hello", "how", "are", "you", "doing"];

localStorage.setItem("test", JSON.stringify(arr));

JSFiddle

Post a Comment for "How To Store Array In Localstorage?"