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 here key is cards and length is nested.
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 here key is cards and length is nested.
Share Improve this question edited Feb 18, 2016 at 10:04 CG_FD 6071 gold badge5 silver badges16 bronze badges asked Feb 18, 2016 at 9:05 Kunal GawhadeKunal Gawhade 311 silver badge2 bronze badges 1- 1 JSON.stringify() and JSON.parse() upon reading? – entio Commented Feb 18, 2016 at 9:07
1 Answer
Reset to default 5localStorage
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