Created
August 2, 2017 00:12
-
-
Save prof3ssorSt3v3/ff50d41496473cfc7755dd747578462f to your computer and use it in GitHub Desktop.
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
// Web Storage | |
// localStorage | |
// sessionStorage | |
// JSON | |
// setItem() | |
// getItem() | |
// clear() - erase everything | |
// removeItem( key ) - delete one item | |
// key( index ) - get the name of one item | |
localStorage.setItem('dude', 'Jeffrey Lebowski'); | |
let val = localStorage.getItem('dude'); | |
console.log(val); | |
let key = 'pacman_highscore'; | |
localStorage.setItem(key, 123123); | |
let options = { | |
"name":"Walter", | |
"game":"bowling", | |
"weapons":["uzi", "pistol", "anger"]}; | |
let str = JSON.stringify(options); | |
localStorage.setItem("TheDude", str); | |
let original = localStorage.getItem("TheDude"); | |
console.log(original); | |
let obj = JSON.parse(original); | |
console.log(obj); | |
console.log(obj.weapons[2]); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment