This may be a really quick answer (or a really stupid question), but I'm trying to store an array of integers so that they can be accessed later locally by another function, at a random time.
Ways I have thought of so far to do this (and their flaws):
- HTML5 data attributes i.e.
data-ids="1,2,3"
(can't store an array easily in these) - HTML5
localStorage
(can only store a string, not an array and would have to convert) - a hidden input i.e.
<input type="hidden">
(again, can't store an array, have to convert into a string)
Ideally I would like to be able to push values onto this locally stored array with syntax like array.push(value)
etc.
Is there an easy way to do this that I'm missing or will I be resorting to hacks? The end use of this array will be comparing with another array of integers to see if any values match, and if there is a match, remove the index from the second array (i.e. it's an array filter).
This array shouldn't be stored on the server because it is different for each user on the client-side. If there is no nice way to do this I'll probably just think about implementing the functionality a different way.