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 :: html string to html 
Javascript :: javascript sum array values by key 
Javascript :: delete first character javascript 
Javascript :: how to get current screen name in react native 
Javascript :: ansi encoding "vscode" 
Javascript :: set value in span using jquery 
Javascript :: heroicons reactjs 
Javascript :: javascript anagram check 
Javascript :: javascript get first 2 char 
Javascript :: self invoked function javascript 
Javascript :: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. 
Javascript :: javascript is number an integer 
Javascript :: js onsubmit prevent default 
Javascript :: how to replace all characters in a string javascript 
Javascript :: Codewars JS Beginner Series #3 Sum of Numbers 
Javascript :: datatable remove show 
Javascript :: chart js no points 
Javascript :: method domain validator js 
Javascript :: reactnavigation 5 hide header 
Javascript :: javascript count elements in json object 
Javascript :: jquery back button event 
Javascript :: UnhandledPromiseRejectionWarning: Error: Node is either not clickable or not an HTMLElement 
Javascript :: javascript get body height 
Javascript :: error java.io.filenotfoundexception tessdata/eng.traineddata 
Javascript :: unix time to date javascript 
Javascript :: import reactdom 
Javascript :: add a route to a buttoin in angular 
Javascript :: cors error in react 
Javascript :: js delete duplicates from array 
Javascript :: javascript show 2 decimal places 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =