I donโt know what the problem is, I got the syntax error in json.parse above. I use the code below
Storage.prototype.setObject = function(key, value) { this.setItem(key, JSON.stringify(value)); } Storage.prototype.getObject = function(key) { var value = this.getItem(key); return value && JSON.parse(value); } function main() { var data = { "a":"something1", "b":"something2" }; sessionStorage.setObject('data',data); var newData = sessionStorage.getObject('data'); console.log(newData); }
when calling getObject ('data') I got an error in "firefox", while "no error" in chrome pls helps me figure out the problem, I run the code on the sample separately, and it works fine for me, but in my to a project where im does something like this, it causes an error.
source share