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 :: how to replace all words in javascript in hindi 
Javascript :: import multiple packages jsp 
Javascript :: get single element typeorm 
Javascript :: react default value for props not showing up 
Javascript :: import image in react js 
Javascript :: jquery event when element is rendered 
Javascript :: material ui hide asterisk 
Javascript :: sequelize findall in array 
Javascript :: format large texts 
Javascript :: js check if tab switched 
Javascript :: not getting jsp option in sts 
Javascript :: getting form value(s) with js 
Javascript :: forintlol 
Javascript :: Pignose Calender 
Javascript :: how to get the number of days in a month in javascript 
Javascript :: json to schema javascript 
Javascript :: JAVASCRPITMAMA 
Javascript :: convert space to dash/hyphen javascript regex 
Javascript :: how to pass information to a type=hidden from a function in javascript 
Javascript :: remove falsy values from object lodash 
Javascript :: take user value and append value in js 
Javascript :: react auto import sometime not working 
Javascript :: window.orientation giving undefined 
Javascript :: convert componentWillUnmount into useEffect 
Javascript :: dropzone alert 
Javascript :: In JavaScript, all numbers are stored in the format float64 
Javascript :: javascript cast everything to string 
Javascript :: jQuery export to Excel with formatting 
Javascript :: Grad points by javascript switch 
Javascript :: javascript pdf 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =