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


#1



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)
}


https://www.codecademy.com/en/courses/spencer-sandbox/4/1?curriculum_id=506324b3a7dffd00020bf661


Replace this line with your code.


#2

Array literals look like this:

[VALUE1, VALUE2, VALUE3, VALUE4]

#3

You definitely can, @jaydacoder!


#4

Would you be able to provide an example?


#5

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