constructor function's object literal returns toString() method but no other method
- by JohnMerlino
I'm very confused with javascript methods defined in objects and the "this" keyword.
In the below example, the toString() method is invoked when Mammal object instantiated:
function Mammal(name){
this.name=name;
this.toString = function(){
return '[Mammal "'+this.name+'"]';
}
}
var someAnimal = new Mammal('Mr. Biggles');…