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

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

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

how to save and use item from local storage javascript

window.localStorage.getItem('user');
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 :: i18n vue cli 
Javascript :: how to round numbers in javscript 
Javascript :: javascript convert image to base64 
Javascript :: js get class property 
Javascript :: change value of variable javascript 
Javascript :: javascript click counter 
Javascript :: tab adds tab textarea javascript 
Javascript :: check for duplicates in array javascript 
Javascript :: count down timer in react native 
Javascript :: how to make back button react 
Javascript :: react bootstrap form select 
Javascript :: how to get selected value of a dropdown menu in reactjs 
Javascript :: date regex format 
Javascript :: react append classname 
Javascript :: javascript document.createElement add function 
Javascript :: Find the maximum number in a jagged array of numbers 
Javascript :: convert currency to string javascript 
Javascript :: tick.json code 
Javascript :: paper material ui 
Javascript :: Iterate object using ngFor in angular 
Javascript :: js know size of screen displayed 
Javascript :: sequelize change column 
Javascript :: react native making bigger hitbox 
Javascript :: angular capitalize first letter 
Javascript :: mongoose unique validator 
Javascript :: ejs display variable 
Javascript :: create new angular project with specific version 
Javascript :: usereducer example 
Javascript :: js date in two weeks 
Javascript :: use setstate in function component 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =