check localstorage key exists code example
Example 1: how to check if local storage variable exists in javascript
if (localStorage.getItem("username") === null) {
//...
}
Example 2: check if localstorage key exists js
if("user" in localStorage){
alert('yes');
} else {
alert('no');
}