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

197
Vistas
How to identify part of the localStorage key in JavaScript?

I have following types of keys in my localStorage,

Key: Designer-96, Value: true
Key: Designer-76, Value: true

On Page_Load() I want to identify if localStorage contains any keys that start with Designer word, if that's the case then I want to execute certain logic.

Is it possible to iterate through the keys of localStorage in JavaScript and find part of the matching key?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can get all keys of localStorge using

Object.keys(localStorage)

and you can then use some to check for the existence of a key starts with Designer

const ls = localStorage;

ls.setItem("Designer-96", true);
ls.setItem("Designer-76", true);

const keys = Object.keys(ls);
if (keys.some((k) => k.startsWith("Designer"))) console.log("Key is present");
else console.log("Key is not present");
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