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