Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js save local storage

//Set item
localStorage.setItem('myCat', 'Tom');
//Get item
var cat = localStorage.getItem("myCat");
//Remove item
localStorage.removeItem("lastname");
//Remove all items
localStorage.clear();
Comment

save to local storage

localStorage.setItem('myCat', 'Tom');

var cat = localStorage.getItem('myCat');

localStorage.removeItem('myCat');

// Clear all items
localStorage.clear();
Comment

how to save and use item from local storage javascript

window.localStorage.setItem('name', 'Obaseki Nosa');
Comment

javascript save data to local storage

// Store
localStorage.lastname = "Smith";
// Retrieve
document.getElementById("result").innerHTML = localStorage.lastname;
// Remove
localStorage.removeItem("lastname");
Comment

how to save and use item from local storage javascript

window.localStorage.getItem('user');
Comment

how to save and use item from local storage javascript

const person = {
    name: "Obaseki Nosa",
    location: "Lagos",
}

window.localStorage.setItem('user', JSON.stringify(person));
Comment

save to local storage

var cat = localStorage.getItem('myCat');
Comment

save data to local storage


//useEffect(function (){}, []) this hook takes function as its first argument and an array/dependency as 
//which if the [] arrray is empty it runs once, meaning on initial render
useEffect(() => {
  const previousData = JSON.parse(localStorage.getItem("Todos"));
  setTodos(previousData);
},[])
//and if something changes in the dependency's value in this case inputText the function that is passed as the first argument runs each time
useEffect(() => {
 localStorage.setItem('Todos', JSON.stringify(Todos));
}, [inputText])



Comment

PREVIOUS NEXT
Code Example
Javascript :: scroll to div bottom 
Javascript :: react js photo gallery 
Javascript :: sessionstorage in javascript 
Javascript :: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 
Javascript :: error: Error: Unable to resolve module `crypto` from `node_modulescrypto-jscore.js`: crypto could not be found within the project. 
Javascript :: react native panresponder on click 
Javascript :: sequelize queryinterface select 
Javascript :: javascript if equal infinity 
Javascript :: tinymce react 
Javascript :: difference between || and ?? in js 
Javascript :: Use the parseInt Function with a Radix Javascript 
Javascript :: dom js 
Javascript :: readline nodejs 
Javascript :: What are "res" and "req" parameters in Express functions 
Javascript :: Import A Module In ExpressJS 
Javascript :: sequelize change item 
Javascript :: service worker.js 
Javascript :: backbone js 
Javascript :: default value of functin atribute 
Javascript :: javascript break out of map 
Javascript :: Angular passing function as component input 
Javascript :: setup error handler in express framework 
Javascript :: javascript continue with while Loop 
Javascript :: deploy node app to heroku 
Javascript :: samoglasnici-vowels 
Javascript :: react faq 
Javascript :: Sha256 decrypt javascript 
Javascript :: Geometery parsing GeoJSON 
Javascript :: vue prop using variable 
Javascript :: bind() in javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =