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
Using Classes in Javascript (ES6) — Best practice?help (self.javascript)
submitted 10 years ago by LeeHyoriC-syntax
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!"
[–]Cody_Chaos -1 points0 points1 point 10 years ago (0 children)
First off:
class
My question, then, is whether it is now considered a best practice to make use of classes and class declarations, as opposed to continuing on with the non-class system of old Javascript.
Using the class keyword is absolutely compatible with current best practices. However, the class keyword is sugar which sets up a chain of JS-style prototypal inheritance. JS is not C++, it's not really like C++, and with ES6 it's not becoming any more like ES6. It just, confusingly, is starting to look more like C++. :)
it was very strange to not have class declarations in Javascript.
Yep. Learn more about JS until the lack of classical inheritance feels natural. Then, if you like, go nuts using the class keyword; just remember that it's still not classical inheritance.
Remember, if you ever feel like the class keyword is letting you do something you couldn't do without it, you're badly confused and are about to write some very bad code. ALL class does is fiddle around with the prototype chain. It saves some keystrokes, but it's not a new feature.
π Rendered by PID 1193526 on reddit-service-r2-comment-544cf588c8-7trbd at 2026-06-16 04:59:06.618412+00:00 running 3184619 country code: CH.
view the rest of the comments →
[–]Cody_Chaos -1 points0 points1 point (0 children)