get local storage value code example

Example 1: get localstorage

function get(){
    var getJson = localStorage.getItem('key')
    if(getJson){
        arrayName = JSON.parse(getJson)
    }
}

Example 2: store data in localstorage javascript

var testObject = { 'one': 1, 'two': 2, 'three': 3 };

// Put the object into storage
localStorage.setItem('testObject', JSON.stringify(testObject));

// Retrieve the object from storage
var retrievedObject = localStorage.getItem('testObject');

console.log('retrievedObject: ', JSON.parse(retrievedObject));

Example 3: local storage javascript

localStorage.setItem('user_name', 'Rohit'); //store a key/value
var retrievedUsername = localStorage.getItem('user_name'); //retrieve the key

Example 4: javascript get local storage

var Item = localStorage.getItem('youritem');

Example 5: get localstorage

var pull=JSON.parse(localStorage.getItem('data'))
for(var i=0; i<pull.length; i++){
    new arrayName(pull[i].AnyName, pull[i].AnyName, pull[i].AnyName)

Example 6: localstorage.getitem()

//The following snippet accesses the current domain's local Storage object 
//and adds a data item to it using Storage.setItem().
localStorage.setItem('myCat', 'Tom');

//The syntax for reading the localStorage item is as follows:
const cat = localStorage.getItem('myCat');

//The syntax for removing the localStorage item is as follows:
localStorage.removeItem('myCat');

//The syntax for removing all the localStorage items is as follows:
localStorage.clear();