Object prototype of __proto__

The object will have a point to __proto__ prototype prototype object constructor, the object was able to use the prototype prototype object constructor method, it is because there is __proto__ prototypes.

      function Student(name, age) {
        this.name = name
        this.age = age
      }
      Student.prototype.study = function() {
        console.log (this.name + 'learning')
      }
      var zs = new Student ( 'John Doe', 18)
      console.log(zs) 
Although there is no way to define zs object, but the system is automatically added to the prototype object __proto__ zs directed to the object constructor function of the body.
 

Find the rules object method: zs when there is a study method of the object body, the study method of execution zs target body. If no such method zs target body, the prototype object prototype constructor who find the study method

 

Guess you like

Origin www.cnblogs.com/perse/p/12037834.html