Coder Social home page Coder Social logo

Confusing info about js-function-context-this HOT 5 OPEN

raq929 avatar raq929 commented on September 16, 2024
Confusing info

from js-function-context-this.

Comments (5)

gaand avatar gaand commented on September 16, 2024 2

Could we add

foo.call( obj2 ) // this === obj2
obj1.foo() // this === obj1

Also, could we not use the name foo in different ways in this list (uncapitalized constructor function, method - key lookup in an object, a regular function, yada)?

from js-function-context-this.

jrhorn424 avatar jrhorn424 commented on September 16, 2024 1

Binding isn't a very good word here, either.

from js-function-context-this.

jrhorn424 avatar jrhorn424 commented on September 16, 2024

obj1.foo().call(someOtherObject)

That's an explicit binding, which is not what the quoted text is referring to.

Is the function called with a context (implicit binding)

I think the parenthetical is important. It should be a parenthetical.

I'm not sure when to re-emphasize that this is not determined until the function is called. It's one of those things, like the definition of a callback, that I drill into them when I deliver this talk.

from js-function-context-this.

raq929 avatar raq929 commented on September 16, 2024

Yeah. I drilled it too. Maybe that has to be enough?

from js-function-context-this.

MicFin avatar MicFin commented on September 16, 2024

After discussing with @gaand, the example would be more appropriately shown as:

obj1.foo() // this === obj1
obj1.foo.call( obj2 ) // this === obj2

from js-function-context-this.

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.