how to check if localstorage has existing key code example
Example 1: check if localstorage key exists js
if("user" in localStorage){
alert('yes');
} else {
alert('no');
}
Example 2: how to check is the key of a localstorage is emopty
if (localStorage.getItem("username") === null) {
//...
}