# Avoid indexing the keys in a Javascript array

I need a data structure to store feeds in columns into tabs.

So the pseudo structure would be:

First Tab : name (string)
First column
First feed : (url (str), type (str), limit (int))
Second feed : (url (str), type (str), limit (int))
Second column
First feed : (url (str), type (str), limit (int))
Second feed : (url (str), type (str), limit (int))
Third feed : (url (str), type (str), limit (int))
Second Tab : name (string)
First column
First feed : (url (str), type (str), limit (int))
Second column
First feed : (url (str), type (str), limit (int))


... And so on.

Now this works:

  var feeds = [
{"groupName":"News",
"0": [
],
"1": [
]
},
{"groupName":"Comics",
"0": [
]
}
];


But

1. I want to avoid maintaining a numerical index for the column keys ;
2. I'm not sure it's the right data structure type.

Apparently the form above is a JavaScript literal object, that is, not an array and not JSon. This is a problem, I want to use the right data structure for what I intend to do with it : At one point in time, I need to validate variables against this data structure, that is to say "OK, this variable is a proper list of feeds". I also need to easily add, delete and rename elements, and from what I can see, there are at least 3 approaches to "arrays" in JavaScript, each with its own set of idiosyncrasies, methods and tools, dos and don'ts ; The context is JavaScript (module pattern) in the browser, and JQuery is available.

So I guess my question is twofold:

• What is the best data structure in this context to allow easy manipulation later ;
• Is there a way to have unnamed columns containing non-indexed feeds?
• Is there some reason you don't just want to add a columns property to the group entity and use a real array there? feeds = { groupName: "News", columns: [ [ {url, type, limit } ], [ {url, type, limit} ] ] } – Gerrit0 Mar 10 '18 at 22:15
• @Gerrit0 Hi ; No, no reason, I just need it to work, for now this structure seems to disagree with JSlint: 1-He doesn't want elements with only values and no key, and 2-It says duplicate key: 'groupName' and BTW I'm having a hard time understanding this one: Duplicate key? Of course I want to duplicate keys..? I must be missing something big, thanks a lot for helping. – yPhil Mar 10 '18 at 22:23

You don't need to label object fields 0 or 1. On each Tab, you could have a field columns which is an array, of arrays containing the feeds in the column as so:

const Tabs = [
{
groupName: "News"
columns: [
[
],
[
]
]
},
{
groupName: "Comics",
columns: [
[