How could I use
window.localStorage.getItem();
to specify items in localstarage that start with the string 'QQ'
. In my case the key can be: QQ + 3 digits, so I just need to specify that it starts with the string 'QQ'
...?
You don't, get all the items and check them individually (code not tested):
var results = [];
for (i = 0; i < window.localStorage.length; i++) {
key = window.localStorage.key(i);
if (key.slice(0,2) === "QQ") {
results.push(JSON.parse(window.localStorage.getItem(key)));
}
}
If you want to do queries use something like IndexedDB.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With