S
S
sergey_from_saratov2018-02-09 11:52:46
JavaScript
sergey_from_saratov, 2018-02-09 11:52:46

How to take variables by mask localstorage?

I have localstorage variables with keys like TODAY_09022018, TODAY_09022019, TODAY_09022020....
How can I take them into the foreach loop using the TODAY_ mask?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Mashletov, 2018-02-09
@sergey_from_saratov

for (var key in localStorage){
   // сравниваешь key по маске, получаешь getItem нужные.
}

A
Alexander, 2018-02-09
@NeiroNx

for(x in localStorage){
   if(x.indexOf("TODAY_")==0){
      console.log(localStorage[x])
   }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question