如何在本地存储中存储数组?
2022-08-29 22:28:21
如果我不需要 localStorage,我的代码将如下所示:
var names=new Array();
names[0]=prompt("New member name?");
这有效。但是,我需要将此变量存储在localStorage中,并且它被证明是相当顽固的。我试过了:
var localStorage[names] = new Array();
localStorage.names[0] = prompt("New member name?");
我哪里出错了?