“LocalStorage Set Item” Réponses codées

JavaScript définit la valeur de stockage locale

var testObject = { 'one': 1, 'two': 2, 'three': 3 };

// Put the object into storage
localStorage.setItem('testObject', JSON.stringify(testObject));

// Retrieve the object from storage
var retrievedObject = localStorage.getItem('testObject');

console.log('retrievedObject: ', JSON.parse(retrievedObject));
Mobile Star

Comment définir le stockage de session en javascript

// Save data to sessionStorage
sessionStorage.setItem('key', 'value');

// Get saved data from sessionStorage
let data = sessionStorage.getItem('key');

// Remove saved data from sessionStorage
sessionStorage.removeItem('key');

// Remove all saved data from sessionStorage
sessionStorage.clear();
Sleepy Sandpiper

localstorage setItem javascript

let fruits = [
	{ name: 'apple', color: 'red', number: 1 },
  	{ name: 'orange', color: 'orange', number: 2 }
]
localStorage.setItem("saved_fruits", JSON.parse(JSON.stringify(fruits)));
Thyago Mac

JavaScript localstorage

localStorage.setItem('user_name', 'Rohit'); //store a key/value
var retrievedUsername = localStorage.getItem('user_name'); //retrieve the key
Grepper

stockage local

// localStorage for objects, arrays or any data type
var obj = {
	firstName: "Bob",
    lastName: "Jeff",
    age: 13
}
localStorage.setItem("itemname", JSON.stringify(obj)); // Save the obj as string
var item = JSON.parse(localStorage.getItem("itemname")); 
// ^^ Parse string then set `item` as the obj
sunst0rm

LocalStorage Set Item

localStorage.getItem('data')
localStorage.setItem('token', 'token here');
localStorage.removeItem('token');
Witty Weevil

Réponses similaires à “LocalStorage Set Item”

Questions similaires à “LocalStorage Set Item”

Plus de réponses similaires à “LocalStorage Set Item” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code