美文网首页
this 指向

this 指向

作者: zhulichao | 来源:发表于2020-08-05 10:16 被阅读0次
var myObject = {
  foo: 'bar',
  func: function() {
    var self = this;
    console.log('outer func:this.foo = ', this.foo); // bar
    console.log('outer func:self.foo = ', self.foo); // bar
    (function(){// 立即执行函数,没有 this
      console.log('inner func:this.foo = ', this.foo); // undefined, this 指向 window
      console.log('inner func:self.foo = ', self.foo); // bar
    }());
  }
};
myObject.func();

相关文章

  • this指向以及改变this指向

    改变this指向 call() apply() bind()

  • this指向

    this指向: 简单的一句话,谁调用的函数,this就指向谁 例子: var obj = { fun1: func...

  • this指向

    axios.get('/api', {params: {name: "kerwin",age:100}}).the...

  • this指向

  • this指向

    例 例

  • this 指向

    window.name = 'xiaoyu' var myObj = {name: 'seven',getName...

  • 指向

    平静的海托着翻飞的火焰,离开港口就有多少离人的泪还会再次上演,看着手上的钟表计算着离开的航线,肃穆的夜还有一串星火...

  • this 指向

    this执行全局环境中 this 指向 window this很重要的解析 https://segmentfaul...

  • this指向

    // 在普通函数中,函数的调用者是window对象,所以函数中的this指针指向的是window,通过访问this...

  • 指向

    飘飘荡荡,所有的事情都在直指一个方向 珍惜所有的付出,不在一处能回馈的也必会找到另一种方式。愿长长久久

网友评论

      本文标题:this 指向

      本文链接:https://www.haomeiwen.com/subject/lrxphktx.html