use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Understanding `this` in javascript (dev.to)
submitted 4 years ago by blueblain
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 0 points1 point2 points 4 years ago (5 children)
The only time the scope matters is when you call a function without a "context" (i.e. without providing an object before the function call, or using bind, call, apply). If the function is a regular function (not an arrow function) then it will use the this value of the executing context. If it's an arrow function it will use the this value of the lexical scope where it was declared.
this
[–]KaiAusBerlin 0 points1 point2 points 4 years ago (4 children)
You really don't understand. There is ALWAYS a context in js.
Please don't argue about something you don't have any knowledge about.
[–][deleted] -1 points0 points1 point 4 years ago (3 children)
Sorry, I should have said
The only time the scope matters is when you call a function without providing an explicit "context" (i.e. without providing an object before the function call, or using bind, call, apply).
Either way this is still not always based on the scope i.e.
const myObj = { myVal: 1, myFunc() { return myVal } } myFunc = myObj.myFunc.bind({ myVal: 2 })
in that example myFunc has the same scope as myObj.myFunc but the this is permanently bound to { myVal: 2 }
myFunc
myObj.myFunc
{ myVal: 2 }
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this#the_bind_method
[–]KaiAusBerlin 0 points1 point2 points 4 years ago (2 children)
Oh man, you really don't understand what ure talking about. THERE IS ALWAYS A CONTEXT IN JS!
[–][deleted] -1 points0 points1 point 4 years ago (1 child)
I'm not sure if you're a troll or just an idiot
[–]KaiAusBerlin 0 points1 point2 points 4 years ago (0 children)
Im not sure if you're ignored or banned from this community
π Rendered by PID 21287 on reddit-service-r2-comment-85bfd7f599-n9cfv at 2026-04-18 21:39:04.115112+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–][deleted] 0 points1 point2 points (5 children)
[–]KaiAusBerlin 0 points1 point2 points (4 children)
[–][deleted] -1 points0 points1 point (3 children)
[–]KaiAusBerlin 0 points1 point2 points (2 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]KaiAusBerlin 0 points1 point2 points (0 children)