Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!