Created
November 9, 2018 00:09
-
-
Save Ujjwal0501/d675baf57cd2a76a83b1453830d186af to your computer and use it in GitHub Desktop.
This file contains 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
# sessionStorage | |
store a value `sessionStorage["key"] = "value";` | |
## Store multiple values | |
- to store values "one", "two", "three" | |
store as follows : `sessionStorage['key"] = ["one", "two", "three"];` | |
- to retrieve multiple values stored use as follows | |
`var array = sessionStorage["key"].toString().split(",");` | |
## Integer values | |
Integer values are not directly accessible without any conversion. So they should be converted as follows | |
- var id = Number(String(sessionStorage["key"])); | |
## Check if key exists/ data is already availble (only case when tab is reloaded) | |
`if (sessionStorage["idd"]) console.log("exists");` | |
[sessionStorage Reference](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment