STORE DATA
//key value pair
localStorage.setItem("username1", "ElonMusk");
localStorage.setItem("username2", "JohnDoe");
REDRIVE DATA
// keyname
// let usernameOne = localStorage.getItem("username1");
// console.log(usernameOne);
let usernameTwo = localStorage.getItem("username2");
console.log(usernameTwo);
//! REMOVE DATA
localStorage.removeItem("username1");
ALL DELETE
localStorage.clear();
STORE DATA
// sessionStorage.setItem("Elon","Musk");
// sessionStorage.setItem("John","Doe");
sessionStorage.setItem("username1", "ElonMusk");
sessionStorage.setItem("username2", "JohnDoe");
REDRIVE DATA
// keyname
let usernameOne = localStorage.getItem("username1");
console.log(usernameOne);
// let usernameTwo= localStorage.getItem("username2");
// console.log(usernameTwo);
REMOVE DATA
sessionStorage.removeItem("username1");
ALL DELETE
sessionStorage.clear();
JSON
obj eppdi localStoragelaa store pannrathu.
let user = {
id: 1,
name: "Elon Musk",
age: 50,
};
STORE TO LOCAL STORAGR
//OBJ TO ONVERT JSON
localStorage.setItem("user", JSON.stringify(user));
//REDRIVE PANNI PAAKA
//JSON stringify TO CONVERT obj
let Isuser = JSON.parse(localStorage.getItem("user")); // key
console.log(Isuser);
Top comments (0)