Answers for "how to check if localstorage is empty javascript"

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 local storage is used or empty

if (localStorage.length > 0){
    //Items are stored in local storage
}else{
    //Local storage is empty
}
Posted by: Guest on August-17-2021

Code answers related to "how to check if localstorage is empty javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language