fucntion Animal(name){ this.name = name; } Animal.size = "middle"; Animal.property.say = function(){ console.log(this.name + 'say'); } var cat = new Animal('coco');
Animal embodiment the code was originally a regular function, when we use new line of code in the last time, this time is the Animal constructor;
After 1.new method inherits the properties of the prototype chain;
Example 2. a constructor;
In addition instanceof principle:
console.log(cat instanceof Animal);
// var L = cat.__proto__; // var R = Animal.prototype; // if(L === R) // return true;