Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 25, 2019 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/4192b0c9a12feca013917e63be63a215 to your computer and use it in GitHub Desktop.
Save parzibyte/4192b0c9a12feca013917e63be63a215 to your computer and use it in GitHub Desktop.
// Recuperar elementos
// No parsear porque lo queremos como cadena
let nombre = localStorage.getItem("nombre");
console.log("Te llamas ", nombre);
// convertir a entero
let edad = parseInt(localStorage.getItem("edad"));
console.log("Tu edad es: ", edad);
// Convertir a booleano
let recibirNotificaciones = Boolean(localStorage.getItem("recibirNotificaciones"));
console.log("¿Quiere recibir notificaciones?", recibirNotificaciones);
// Y a objeto
let mascotaDecodificada = JSON.parse(localStorage.getItem("mascota"));
console.log("La mascota es: ", mascotaDecodificada);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment