js关于this指向问题,this 到底指向了哪里?

 var a = 1
    function text () {
        console.log(this,1111)
        
        console.log(this.a,'hello')
    } 
    function text_a () {
        var a = '2'
        console.log(this,'hello world')
        console.log(this.a,'world')
        text()
    }text_a()

在 text_a 里调用了 text() 方法 , 此时 text() 方法内部的 this 应该指向哪里 ? 为什么 ?

阅读 938
1 个回答
  • 操作 this 内置函数(apply, call, bind)
  • 该函数是一个对象的方法,则它的 this 指针指向该对象
  • new 操作符调用函数
  • 普通函数的this,由“调用它所使用的引用”决定(即window,严格模式下,为undefined
  • 箭头函数
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题