10、原型链

function Foo(){
  Foo.a = function(){
    console.log(1)
  }
  this.a = function(){
    console.log(2)
  }
}
Foo.prototype.a = function(){
  console.log(3)
}
Foo.a = function(){
  cosnole.log(4)
}

Foo.a();    //4
let obj = new Foo();        //new Foo()的时候也会吧Foo当作一个函数执行;此时Foo上的属性a  =>1,其中this指obj,obj.a =>2
obj.a();    //2
Foo.a(); //1

results matching ""

    No results matching ""