The method used for make an array 26/33


I have a question about the way the array is constructed in this lesson.
up until now I have only been taught to construct arrays like this:

var myArray = [22, "word", true];

In this lesson, they use this method:
var family = new Array();
family[0] = new Person("alice", 40);
family[1] = new Person("bob", 42);
family[2] = new Person("michelle", 8);
// add the last family member, "timmy", who is 6 years old
family[3] = new Person("timmy", 6);

Did I miss a lesson? Because This is the first time I've seen an array constructed this way. I am pretty sure I understand what is happening here and why this would be the preferred method, but I wanted to make sure I didn't miss something in previous lessons. Thanks!


Well, if it is level 26/33, you were supposed to have a function named person (which I do not see, maybe did not show?), also, we do not use this:

in this level. To be honest, I am confused, for they already have this function for you when you start, and what you had to do was to add a person named timmy, not make an object constructor.


Thanks for the reply!

I didn't have any problem with this lesson, my question was about the way they made the array.

I don't remember there being a lesson about how to make an array using new Array() instead of brackets. Maybe I just need to wait until a later lesson.

Thanks again for responding.


Well, just think of it as the new Object(); function, except instead of an object, it's an array.


Thanks, I will do just that!

I also checked the glossary and it gave a more detailed description on using the Array constructor. They really are a lot like objects. Thanks again.