Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
How to retrieve data from local storage in javascript

i have a class called ui and after saving data in local storage using save method it works but when i'm getting the data with loadData method it gives me undefined .. i want to know why ?!!

class UI{ 

 save(key, value) {
  localStorage.setItem(key, value);
 }

 getValue(key) {
  localStorage.getItem(key);
 }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You didn't mention what's the value you are saving to the localStorage. If it's not a primitive data type, you'd need to convert the value into a string before you save it in the localStorage using the JSON.stringify(value) method and when you run getvalue you'd want to parse the stringified value using JSON.parse(localStorage.getItem(key)).

PS: using static methods make sense when you are trying to save or retrieve data to/from the localStorage. Giving access to individual objects to have access to localStorage might cause problems in the future.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda