码迷,mamicode.com
首页 > 其他好文 > 详细

this是如何产生的?浅析一下this的指向问题

时间:2018-10-26 19:26:56      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:调用   apply   style   箭头函数   this   它的   通过   产生   call()   

 

this的产生:一个函数创建时就会产生一个this对象,或者说函数执行时就会产生一个this对象

 

    this的指向

         this指向直接调用它的对象。

         函数的回调函数中的this指向window

 

    this指向的改变

             bind(this):可以改变匿名函数内部的this指向  

             call(this):函数调用时可以改变this指向;

             apply(this):函数调用时可以改变this指向;

 这里要注意的是

        箭头函数没有this,箭头函数中的this继承父级而来。

        箭头函数无法通过bind(),call(),apply()改变this的指向。

this是如何产生的?浅析一下this的指向问题

标签:调用   apply   style   箭头函数   this   它的   通过   产生   call()   

原文地址:https://www.cnblogs.com/bitkuang/p/9857740.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!