GithubHelp home page GithubHelp logo

Comments (3)

Genzhen avatar Genzhen commented on May 1, 2024

答案
c a

解析

  • 原因在于this指向的是函数的执行环境,this取决于其被谁调用了,而不是被谁定义了。
  • 对第一个console.log()语句而言,getFullName()是作为obj.prop对象的一个方法被调用的,因此此时的执行环境应该是这个对象。另一方面,但getFullName()被分配给test变量时,此时的执行环境变成全局对象(window),原因是test是在全局作用域中定义的。因此,此时的this指向的是全局作用域的fullname变量,即a。

from fe-interview.

yaooooooooo avatar yaooooooooo commented on May 1, 2024

?????答不对题啊........

from fe-interview.

Genzhen avatar Genzhen commented on May 1, 2024

?????答不对题啊........

@yaooooooooo 改过来了哈,感谢指正

from fe-interview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.