![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Checking if a key exists in HTML5 Local Storage
The getitem(key) takes value for one parameter and returns the value associated with the key. The given key is present in the list associated with the object.
if(localStorage.getItem("user")===null) { //... }
But if the key is not present in the list then it passes null value by using the below-given code
You can also follow the below-given procedure −
if("user" in localStorage){ alert('yes'); } else { alert('no'); }
Advertisements