26. Can array of object be done using Literal Notation?


This lessons shows how to create an array of Objects using "constructor notation" but I am wondering if this can be done using "literal notation". Can't seem to figure it out.

I know my code is wrong, but to give an example, can we do something like this?

var family = {
  [0]: new Person("alice", 40),
  [1]: new Person("bob", 42),
  [2]: new Person("michelle", 8),
  [3]: new Person("timmy", 6)


Replace this line with your code.


Array literals look like this:



You definitely can, @jaydacoder!


Would you be able to provide an example?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.