javascript get local storage code example

Example 1: get localstorage

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

Example 2: localStorage

// localStorage for objects, arrays or any data type
var obj = {
	firstName: "Bob",
    lastName: "Jeff",
    age: 13
}
localStorage.setItem("itemname", JSON.stringify(obj)); // Save the obj as string
var item = JSON.parse(localStorage.getItem("itemname")); 
// ^^ Parse string then set `item` as the obj

Example 3: javascript get local storage

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

Example 4: 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 5: get specific item from local storage

JSON.parse(localStorage.getItem('user')).id

Example 6: get localstorage

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