I want to settle this confusion in my mind once and for all! I am having trouble reaching some of my class properties and methods. Now, I know I could use a object literal and append all of my references with the objects name, e.i. animal., but I want to know how to handle this with an instantiated class.
Here is a quick example of my code..
function animal(){
this.type = "Reptile";
this.sayType = function(){
//from my experiences "this" right here still refers to "animal"
alert(this.type);
};
this.names = {
name : "Lizard",
sayTypeAndName : function(){
//Now "this" refers to "names" not the "sayTypeAndName" method or the parent
//animal. If I try to refer to "animal" like I would in an object literal
//and construct the class. I get an error saying the method below does
//not exist. HOW DO I CORRECTLY REFER TO THE PARENT CLASS PROPERTIES?
//DO I STICK THE PARENT CLASS PROPERTIES AND METHODS INTO MY "names" object?
animal.sayType(animal.type+" "+this.name);
}
};//end of names object
}//end of class
Thank you all for any help on this