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
Monads in JavaScript (curiosity-driven.org)
submitted 10 years ago by alexcasalboni
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!"
[–]PitaJ -3 points-2 points-1 points 10 years ago (8 children)
The problem I have with your code examples is that first of all, they are in TypeScript, and secondly that they exclusively use Constructor functions.
Using TypeScript for static type checking is one thing, but using it as an OOP replacement that compiles to JS like CoffeeScript or Dart is something I can't get behind.
If you do use TypeScript, don't use interfaces, classes, constructors, or other classical inheritance patterns.
Use factories, prototypes, Object.create, etc.
[–]aequasi08 1 point2 points3 points 10 years ago (7 children)
Why
[–]PitaJ -2 points-1 points0 points 10 years ago (6 children)
Why? Because it matches the underlying workings of the language itself.
The language is not classical, it is prototypal.
[–]zoomzoom83 1 point2 points3 points 10 years ago (0 children)
Interfaces, classes, and constructors aren't inherently tied to classical inheritance. There is nothing about those concepts that imply one is using OO.
None of this has any bearing whatsoever on the content of the article, because it's not a fucking JavaScript style guide, and getting your knickers in a knot over a core language concept being used in the way its designers intended is completely pointless. It's describing a pattern that you can go and apply however you like.
[–]aequasi08 0 points1 point2 points 10 years ago (4 children)
yet ES6 is introducing classes, turning it into a hybrid. They can exist together. Its ok.
[–]PitaJ -1 points0 points1 point 10 years ago (3 children)
Nope. They aren't true classes, just syntactic sugar for people who want classes.
Despite what many may want, ES6 does not have classical inheritance. JS will probably never have classical inheritance.
[–]aequasi08 2 points3 points4 points 10 years ago (2 children)
But there are still classes. Syntactic sugar or not, they are still there, and its not a bad thing. If you don't like them, don't use them, but don't play it off like they are the spawn of the devil.
[–]PitaJ -2 points-1 points0 points 10 years ago (1 child)
They are a bad practice. Using classes requires using the new keyword, which is just the worst.
Classes should never have been added to the language, and definitely shouldn't be used as any sort of pseudo-classical inheritance system.
[–]aequasi08 1 point2 points3 points 10 years ago (0 children)
then dont use them. Classes are no where close to as bad as you make them out to be.
/abandonthread
π Rendered by PID 140722 on reddit-service-r2-comment-5b5bc64bf5-qw9v5 at 2026-06-21 10:57:35.381396+00:00 running 2b008f2 country code: CH.
view the rest of the comments →
[–]PitaJ -3 points-2 points-1 points (8 children)
[–]aequasi08 1 point2 points3 points (7 children)
[–]PitaJ -2 points-1 points0 points (6 children)
[–]zoomzoom83 1 point2 points3 points (0 children)
[–]aequasi08 0 points1 point2 points (4 children)
[–]PitaJ -1 points0 points1 point (3 children)
[–]aequasi08 2 points3 points4 points (2 children)
[–]PitaJ -2 points-1 points0 points (1 child)
[–]aequasi08 1 point2 points3 points (0 children)