How to check if the localStorage key exists or not in JavaScript

1 Answer

0 votes
if (localStorage.getItem("email") !== null) {
    console.log('Key exists');
} else {
    console.log('Key is not found');
}

  
    
    
/*
run:
    
"Key exists"
    
*/

 



answered Jun 29, 2021 by avibootz

Related questions

1 answer 137 views
2 answers 189 views
1 answer 112 views
1 answer 264 views
1 answer 135 views
...