However, you still can use the named array syntax, which will produce an object.
var person = ; //empty array
person[“name”] = “John”;
person[“age”] = 46;
Now, person is treated as an object, instead of being an array.
The named indexes “name” and “age” become properties of the person object.
It is better to use an object when you want the index to be a string (text).
Use an array when you want the index to be a number.
© License: All Rights Reserved
CONTACT HOLLA TECH – LEARN SUPPORT