admin管理员组文章数量:1427307
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
本文标签: javascriptHow to store array in localStorageStack Overflow
版权声明:本文标题:javascript - How to store array in localStorage? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745496238a2660820.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论