I am using Angular1x and I simply want to create an array object with numeric indexes:
var unreadMessagesCookieObject = [];
unreadMessagesCookieObject[id] = {
id: messageObj.id,
lastNotified: moment.getTime()
};
All fine? Well no not really:
(6) [null, null, null, null, null, {…}]
0: null
1: null
2: null
3: null
4: null
5:
id: 1
lastNotified: 1601769147988
Why do I have an object with 5 null indexes. I want to write the Object to a cookie but not the 5 null values.
How can I create an array object with an arbitrary numeric index. Note that I cannot use 0 as my first index since I want to be able to search in the array object by an id.
= {}), not an array (= []).