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 144 views
2 answers 203 views
1 answer 123 views
1 answer 279 views
1 answer 151 views
...