Skip to content

Instantly share code, notes, and snippets.

@Ujjwal0501
Created November 9, 2018 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ujjwal0501/d675baf57cd2a76a83b1453830d186af to your computer and use it in GitHub Desktop.
Save Ujjwal0501/d675baf57cd2a76a83b1453830d186af to your computer and use it in GitHub Desktop.
# 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