Created
August 4, 2016 12:09
-
-
Save ramsunvtech/c7d2c954893142c5fb32d9ea9952e620 to your computer and use it in GitHub Desktop.
Session / Local Storage Exist Check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Creation | |
| localStorage.setItem('firstname', 'Keith'); | |
| // First Approach. | |
| function isExist(name) { | |
| return (!!localStorage[name]); | |
| } | |
| // Second Approach. | |
| function isItemExist(name) { | |
| return (name in localStorage); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment