Answers for "localstorage get and set item"

17

javascript set local storage value

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));
Posted by: Guest on March-07-2020
0

how to setItem and getItem in javascript in localStorage

function set(){
    var sendJSON = JSON.stringify(allMovie);
    localStorage.setItem('allMovie',sendJSON)
}

function get(){
    var getJSON = localStorage.getItem('allMovie');
    if (getJSON){
        allMovie = JSON.parse(getJSON)
    }

}
Posted by: Guest on August-10-2020
0

javascript storage get set item

// *** JS Storage Get/Set item *** 

	let target = document.getElementById("target");
    let increment = document.getElementById("increment");
    let count = localStorage.getItem("counter") || 0;
    target.innerHTML = count;

    increment.addEventListener("click", () => {
        count++;
        localStorage.setItem("counter", count);
        target.innerHTML = count;
    })
Posted by: Guest on October-27-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language