Coder Social home page Coder Social logo

WAT about js-function-context-this HOT 12 CLOSED

ga-wdi-boston avatar ga-wdi-boston commented on August 12, 2024
WAT

from js-function-context-this.

Comments (12)

jrhorn424 avatar jrhorn424 commented on August 12, 2024 1

from js-function-context-this.

gaand avatar gaand commented on August 12, 2024

call is a method on Function.prototype that invokes the function, in this case goBoom, on which it is called with the object passed set to this, in this case deathstar. So, it's equivalent to the following:

const goBoom = function () {
    console.log(this);
};

let deathstar = { goBoom };
deathstar.goBoom();
// this === deathstar

but without actually making goBoom a property of deathstar.

from js-function-context-this.

payne-chris-r avatar payne-chris-r commented on August 12, 2024

Ok. I understand, but I think that sentence might create more confusion than it removes...

from js-function-context-this.

gaand avatar gaand commented on August 12, 2024

I'm not arguing that point, and I'd be happy to see a different explanation (maybe something based on my response to your query?) I'm just trying to address your WAT

from js-function-context-this.

raq929 avatar raq929 commented on August 12, 2024

I would read this as, "Call the function goBoom with deathstar as the context (this)"

Are we trying to clarify the README?

from js-function-context-this.

jrhorn424 avatar jrhorn424 commented on August 12, 2024

I'm more inclined toward @RTS's wording than @payne-chris-r's at the moment.

from js-function-context-this.

gaand avatar gaand commented on August 12, 2024

@raq929's wording seems quite clear to me 🤖 .

from js-function-context-this.

payne-chris-r avatar payne-chris-r commented on August 12, 2024

Good. Than we're all in agreement. I like @RTS' wording better too

from js-function-context-this.

raq929 avatar raq929 commented on August 12, 2024

This accidentally got reverted. 😞

from js-function-context-this.

payne-chris-r avatar payne-chris-r commented on August 12, 2024

I saw that! Noooo. #everythingIsNoLongerAwesome. But it can be again! #nextIteration.

from js-function-context-this.

jrhorn424 avatar jrhorn424 commented on August 12, 2024

How did this reversion happen?

from js-function-context-this.

raq929 avatar raq929 commented on August 12, 2024

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.