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

141
Views
SessionStorage + jQuery: Iterating over all existing keys with name like (wildcard)

I use SessionStorage to store information about selected items to pack. So I have a number of keys like (pack01, pack02, pack07, pack22, etc), but there are also other keys in the SessionStorage too.

I would like to write a function to iterate through all keys that the name starts with (pack) - only these ones.

Sample objects in SessionStorage:

pack01: [{"pack_items":1,"pack_name":"testname1"}] 
pack02: [{"pack_items":2,"pack_name":"testname2"}] 
test: test

Code so far:

for (let i = 0; i < sessionStorage.length; i++) {
      const key = sessionStorage.key(i);
      if(sessionStorage[key].hasOwnProperty('pack_items')){
          console.log(sessionStorage[key]['pack_items']);
      }
      else {
        console.log('FALSE');
      }
      console.log(`${key}: ${sessionStorage.getItem(key)}`);
}

Any advice? Thank you

about 4 years ago · Juan Pablo Isaza
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!