<Hello World />
This is my first story here and I apologize for the bad grammar or bad writing.
Well, the question was whether we have an array with a named index or not?! some said, it is not supported in Js, which is almost true. As I gave a hint, I definitely wanted the console output, and thank you for not checking in console :)
Well, let’s explain first, associative array or hash are actually arrays that we can access with a string key to array’s elements, that are supported in some languages but not in JavaScript.
As it said in JavaScript :
Array with numbered index and Object with named index.
Let’s see the output in console:
So the answer is the third option. Now Wutttttt (Bojack Horseman) ? is it some kind of conflict?
Accessing to the element of an array is through the numbered index (as we saw in the example above), but because arrays are a kind of objects and actually arrays inherit objects, if we use named indexes, JavaScript will redefine the array to a standard object, then recognizes it as a “property” and we can access its value, but it does not affect the length of the array and we can not access it with a numbered index. arrays only recognize numeric properties as their elements and you can use array’s methods on them.
As said in YDKJS: “arrays are special objects, they can also have properties, including the automatically updated length property”.
Well, I do not know how well I explained it, but I hope it will be useful. If not, read You Don’t Know Js book “cuz WE All Don’t Know Js”.