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