I have the following javascript objects. I would like to store the following array on sessionstorageItem
, but it was giving me error. How can I able to store an array in sessionstorageItem
?
data=[];
data[0] = [{
"num": 29,
"ser": 1,
}, {
"num": 44,
"ser": 2,
}]
data[1]=[{
"num": 10,
"ser": 3,
}]
allData = data.reduce(function (a, b) { return a.concat(b) });
// the following line gives me an error
var MDData=JSON.parse(sessionStorage.MDData);
if (MDData!==null) {console.log("Hello")}
sessionStorage.setItem('MyData', JSON.stringify(allData));