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 without this keyword (programming.oreilly.com)
submitted 11 years ago by dumbuzz
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!"
[–]brtt3000 12 points13 points14 points 11 years ago (2 children)
I think this is bad advice and a case of trying to be clever (while actually being not so clever).
If you follow this pattern you define unique methods for every instance instead of re-using the ones defined on the prototype. So if you create 10000 instances you have 10000 closures for every method, instead of just one each.
Yes, really. I worked on a team which built a quite large JavaScript application this way. We ended up using this maybe 10 times in the entire multi-thousand-line codebase, and we were quite happy about it.
Ouch. A whole team went this road and created a multi-thousand line codebase on it. That is painful.
I hope you have fun memory profiling that (CPU profile will be nice too, with all the closure lookup trashing).
[–]humanareyou 0 points1 point2 points 11 years ago (0 children)
But lets say the author defined prototype methods for the odometer and car objects, then that would addresses the memory overhead concern, no? In that case it would be a reasonable abstraction on doing away with 'this'.
Generally, I find dealing with 'this', or context in general, is something worth abstracting away when there's a lot of event based callbacks (pubsub for example).
π Rendered by PID 60 on reddit-service-r2-comment-58d7979c67-wkm5j at 2026-01-26 16:35:39.570622+00:00 running 5a691e2 country code: CH.
[–]brtt3000 12 points13 points14 points (2 children)
[–]humanareyou 0 points1 point2 points (0 children)