javascript - JSON.parse localStorage unexpected end of input error -
this line
item = json.parse(localstorage["item"]);
caused error in console showing uncaught syntaxerror: unexpected end of input
when localstorage has no value? how resolve issue? know empty string not valid json.
if(localstorage["item"]){ item = json.parse(localstorage["item"]); }
Comments
Post a Comment