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 :: send data using fetch 
Javascript :: refresh ajax jquery 
Javascript :: tinymce return text and html 
Javascript :: implement singleton javascript 
Javascript :: Get the <html tag with JavaScript 
Javascript :: double logical not javascript 
Javascript :: javascript append list 
Javascript :: command to check dependencies in angular 
Javascript :: add parameter at the end of url from jquery with refreshing 
Javascript :: JavaScript querySelector - By Attribute 
Javascript :: react-infinite-scroller 
Javascript :: is promise 
Javascript :: encode password javascript 
Javascript :: javascript remove css link 
Javascript :: alertify js vue 
Javascript :: jquery add 
Javascript :: enforcefocus select2 modal 
Javascript :: angular material datepicker range get value 
Javascript :: javascript arreglos 
Javascript :: fade in onscroll jquery 
Javascript :: angular injectiontoken 
Javascript :: react router path array 
Javascript :: Different between for of loop and for in loop in js 
Javascript :: find all of array which satisfy condition javascript 
Javascript :: jquery get textarea value 
Javascript :: js number to str 
Javascript :: react native app crashing on start 
Javascript :: js is variable int 
Javascript :: date range query knex 
Javascript :: ordenar un array de mayor a menor 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =