原型对象中tnis指向

111 阅读1分钟
//1.生声构造函数
function Fu {
  //实例成员
  this.name =nanme;
  this.age =age;
}
//把原型上方法中的this放入变量
let date;
//往原型上挂方法      。      静态成员
Fu.prototype.main =function(){
     date =this;
}
let  lj = new Star('李金',18);
console.log( date === lj); //打印为true,说明原型对象中的this也是指向实例化对象
- 总结:
 this指向问题:构造函数与原型对象的this都是指向实例化对象**
- 一般情况下this指向函数调用者