check local storage empty javascript code example
Example 1: how to check if local storage variable exists in javascript
if (localStorage.getItem("username") === null) {
//...
}
Example 2: getItem local storage doesnt exist
if (localStorage.getItem("username") === null) {
//...
}