Can't get object constructor to pass other objects as parameters
I have a code set up something like this:
////////////////////////////////////////
function person()
{
this.age = 25;
}
function dog()
{
this.breed = "Retriever";
}
function house(a_person,a_dog)
{
this.dad = a_person;
this.dog = a_dog;
}
var Andy = new person();
var Fluffy = new dog();
var Family = new house(Andy,Fluffy);
/////////////////////////////////////////
The problem is I keep getting an error along the lines of:
TypeError: Result of expression 'house' [[object Object]] is not a constructor.
It seemed to work when I wasn't passing the other objects as parameters in the constructor. I just created and assigned them later. As in:
/////////////////////////////
function house()
{
this.dad;
this.dog;
}
var Andy = new person();
var Fluffy = new dog();
var Family = new house();
Family.dad = Andy;
Family.dog = Fluffy;
//////////////////////////////
So what's wrong with passing them as parameters in the constructor itself?