How to store an array of objects in Local Storage?

前端 未结 3 1174
迷失自我
迷失自我 2021-01-30 17:44

This is my code. I am trying since a couple of days to create an Array of Objects, which I will then store in Local Storage. Here is the problem, I need to first Get the existin

3条回答
  •  粉色の甜心
    2021-01-30 18:29

    Try something like this:- link https://jsfiddle.net/sureshraina/nLexkyfw/1/

    var mydatas = new Array();
            mydatas[0] = "data";
            mydatas[1] = "data1";
            mydatas[2] = "data2";
    
            localStorage["mydatas"] = JSON.stringify(mydatas);
    
            var datas = JSON.parse(localStorage["mydatas"]); 
    

提交回复
热议问题