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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -