26. Arrays of Objects


I am confused about this line:
var family = new Array();

Here is the entire code:
var family = new Array();
family[0] = new Person("alice", 40);
family[1] = new Person("bob", 42);
family[2] = new Person("michelle", 8);

Previously, when we learned about arrays, it was in this construct:
var family = [data, data, data];

and I am having a hard time transitioning from what we learned about making arrays in the previous lesson and this new array syntax. Can someone explain the new sytax? Is there another way to write an array for this lesson that would be less confusing?



var family = new Array()
create an empty array object it's like var family = []
this is two way for the same thing.
With new Array() you can define the length of your array
var family = new Array(5);
console.log(family.length); // display 5

Sorry for my bad english