How would it be possible to return an object containing all localStorage keys/values? Mainly to future-proof code as best as possible, rather than declaring known keys to store, I’m looking for a way to get everything.
For context: This will be used in a Chrome extension to synchronize preferences.
If you wanted to do that, you could simply loop through each item, and append the current item, separated by a space.
I put a space between each key and value so that you can use a Tokenizer or something similar to break apart using spaces as delimiters. You could add in a “Key”+i and/or “value”+i descriptor in front of each item to aid in parsing or looking for an item without having to loop through keys to find the matching one.