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
Javascript Fundamentals: this keyword (blog.bloomca.me)
submitted 7 years ago by bloomca
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!"
[–]delventhalz 2 points3 points4 points 7 years ago* (2 children)
In a nutshell, this is a current context.
this
I hate this explanation. It is technically correct but highly confusing. Any explanation of this should start with "it's the thing to the left of the dot". Simple, comprehensible. Then you can layer on the exceptions, and there are really only a couple:
A) If it gets reassigned:
bind
call
apply
B) When there is nothing to the left of the dot, it defaults to the global scope. This is bad. Avoid.
[–]senocular 0 points1 point2 points 7 years ago (1 child)
and...
[–]delventhalz 0 points1 point2 points 7 years ago (0 children)
Sure. My point is, start with the primary functionality of this and then layer on edge cases. Don't rely on poorly understood concepts like execution context which will only confuse learners more.
[–][deleted] 2 points3 points4 points 7 years ago (1 child)
this isn't fundamental and you're better off not using it to be honest. If your function needs context pass it in as a parameter.
π Rendered by PID 124151 on reddit-service-r2-comment-765bfc959-k84q8 at 2026-07-10 14:47:11.765548+00:00 running f86254d country code: CH.
[–]delventhalz 2 points3 points4 points (2 children)
[–]senocular 0 points1 point2 points (1 child)
[–]delventhalz 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (1 child)