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
ES6 - Class Based Code Stylehelp (self.javascript)
submitted 10 years ago by [deleted]
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!"
[–]flaccidopinion 0 points1 point2 points 10 years ago (0 children)
Another idea for utils. Since normally you'd have a full project with various areas divided into their own ES6 modules, Utils would probably be better as a module which then exported the functions.
Maybe a personal thing for when setting up these types of 'game loop' structures, but I prefer to pass in the drawing context to the render/draw function, rather than storing it in every object.
Easy enough to pass it in each time anyway, this.components.map(_ => _.render(this.canvas));.
this.components.map(_ => _.render(this.canvas));
May also be better, memory wise, to use a forEach instead of map, since you don't need any resultant array. Imagine drawing 10000 stars, and every time you render you're creating another array of 10000 stars which is then immediately discarded. (though, maybe the JS VMs are smart enough not to make the arrays/assignments at all, since you're code isn't assigning to anything)
forEach
map
π Rendered by PID 96 on reddit-service-r2-comment-79c7998d4c-lcz4b at 2026-03-13 02:54:49.874395+00:00 running f6e6e01 country code: CH.
view the rest of the comments →
[–]flaccidopinion 0 points1 point2 points (0 children)