Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 25, 2019 19:37
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/82550a28882fc741f774cc7d69e692ae to your computer and use it in GitHub Desktop.
Save parzibyte/82550a28882fc741f774cc7d69e692ae to your computer and use it in GitHub Desktop.
const funcionaLocalStorage = () => {
// Si no existe el objeto, pues no hay soporte
if(!window.localStorage) return false;
// Ahora intentamos insertar y eliminar
try{
let id = "un_id_que_no_debe_repetirse";
localStorage.setItem(id, "Soy un valor");
localStorage.removeItem(id);
return true;
}catch(e){
// Está lleno, está en modo privado, o cualquier cosa
console.log(e);
return false;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment