KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a variable which is an array and I want every element of the array to act as an object by default. To achieve this, I can do something like this in my code. var sample = new Array(); sample[0] = new Object(); sample[1] = new Object(); This works fine, but I don't want to mention any index number. I want all elements of my array to be an object. How do I declare or initialize it? var sample = new Array(); sample[] = new Object(); I tried the above code but it doesn't work. How do I initialize an array of objects without using an index number?
Tags (comma-separated)
Save Edits
Cancel