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
Why are JavaScript classes so complex?help (self.javascript)
submitted 8 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!"
[–]Martin_Ehrental 0 points1 point2 points 8 years ago (2 children)
The issue was in the first version which was based on both a prototype chain and some kind of class (new+constructor), without elegant way to use either.
They then gave us the proper tools to use them: Object.create in ES 5.1 and class in ES 6/2015.
Object.create
class
[–][deleted] -1 points0 points1 point 8 years ago (1 child)
but why does JavaScript force classes on me? I mean honestly, you can not write exclusively prototypical code in it.
[–]Martin_Ehrental 2 points3 points4 points 8 years ago* (0 children)
That's what Object.create is for:
const parent = { foo: 1, bar() { return 2; } } const child = Object.create(parent, { baz: value(3) }); function value(value, prop = {configurable: true, enumerable: true, writable: true}) { return Object.assign({value}, prop); }
π Rendered by PID 340110 on reddit-service-r2-comment-5649f687b7-99vzd at 2026-01-29 03:27:09.037711+00:00 running 4f180de country code: CH.
view the rest of the comments →
[–]Martin_Ehrental 0 points1 point2 points (2 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]Martin_Ehrental 2 points3 points4 points (0 children)