1var testObject = { 'one': 1, 'two': 2, 'three': 3 };
2
3// Put the object into storage
4localStorage.setItem('testObject', JSON.stringify(testObject));
5
6// Retrieve the object from storage
7var retrievedObject = localStorage.getItem('testObject');
8
9console.log('retrievedObject: ', JSON.parse(retrievedObject));
1function createItem() {
2 localStorage.setItem('nameOfItem', 'value');
3}
4createItem() // Creates a item named 'nameOfItem' and stores a value of 'value'
5
6function getValue() {
7 return localStorage.getItem('nameOfItem');
8} // Gets the value of 'nameOfItem' and returns it
9console.log(getValue()); //'value';
1localStorage.setItem('user_name', 'Rohit'); //store a key/value
2var retrievedUsername = localStorage.getItem('user_name'); //retrieve the key
1function set(){
2 var sendJSON = JSON.stringify(allMovie);
3 localStorage.setItem('allMovie',sendJSON)
4}
5
6function get(){
7 var getJSON = localStorage.getItem('allMovie');
8 if (getJSON){
9 allMovie = JSON.parse(getJSON)
10 }
11
12}
1localStorage.getItem('data')
2localStorage.setItem('token', 'token here');
3localStorage.removeItem('token');
1function set(){
2 var sendJson = JSON.stringify(arrayName);
3 localStorage.setItem('key',sendJson)
4}