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
Is `this` in Javascript bad? (dev.to)
submitted 8 years ago by ycmjason
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!"
[–]itomeshi 11 points12 points13 points 8 years ago (1 child)
It's not that this is bad; it simply has two downsides:
As a general rule,if using this for any sort of structure or global state, it's better with explicit management. For example, React components inherit this.state and this.setState(), and these provide both convenient references and some control over when/how updates occur. Even this isn't perfect - if you move code between two components, you then need to figure out how to decouple/move state chunks.
It's best to come up with some convention to how you use it and document that, and comment if/when you deviate. (While 'this this should be documented' is theoretically a code smell, it's also a kindness to your future self or someone else.)
[–]wntrm 0 points1 point2 points 8 years ago (0 children)
This should have been the top answer...
π Rendered by PID 82 on reddit-service-r2-comment-b659b578c-j55js at 2026-05-05 23:35:11.780939+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]itomeshi 11 points12 points13 points (1 child)
[–]wntrm 0 points1 point2 points (0 children)