“API de LocalStorage” Código de respuesta

Guardar en el almacenamiento local

localStorage.setItem('myCat', 'Tom');

var cat = localStorage.getItem('myCat');

localStorage.removeItem('myCat');

// Clear all items
localStorage.clear();
Tame Toucan

JS LocalStorage

> Add item
localStorage.setItem('foo', 'bar');
> Get item
localStorage.getItem('foo');
> Remote item
localStorage.removeItem('foo');
> Clear all
localStorage.clear();
Code Cat

almacenamiento 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

JavaScript LocalStorage

localStorage.setItem("user_name", "Bob");

document.body.addEventListener("click", function(){
  alert(localStorage.getItem("user_name"))
});
Breakable Baboon

LocalStoray JS

// Set
localStorage.setItem('monChat', 'Tom');

// Get
localStorage.getItem('myCat');

// Remove
localStorage.removeItem('myCat');
Lively Leopard

API de LocalStorage

localStorage //to see localStorage data
localStorage.clear() // to clear all the localStorage data
localStorage.setItem("something") // to set a localStorage Item
localStorage.getItem("something") //to read the localStorage data
localStorage.removeItem("something") // to remove the localStorage data
Disturbed Dingo

Respuestas similares a “API de LocalStorage”

Preguntas similares a “API de LocalStorage”

Más respuestas relacionadas con “API de LocalStorage” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código