When creating an object (before ES6), you can create an instance of the object this way ...
var Animal = function(){}
and then
var dog = new Animal();
...
Inside the "class" of animals, you can add ...
var Animal = function( name ){
this.constructor.prototype.name = name;
}
The main question is: what is the difference between using regular thisversus usingthis.constructor.prototype
var Animal = function( name ){
this.constructor.prototype.name = name;
this.name = name;
}
I know such a basic one if someone wants to explain. Thanks in advance!
source
share