Answers for "how to check if key exist in local storage in js"

5

how to check if local storage variable exists in javascript

if (localStorage.getItem("username") === null) {
  //...
}
Posted by: Guest on February-28-2020
0

check if localstorage key exists js

if("user" in localStorage){
   alert('yes');
} else {
   alert('no');
}
Posted by: Guest on July-04-2020

Code answers related to "how to check if key exist in local storage in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language