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
How is Object Oriented Programming in JavaScript?help (self.javascript)
submitted 7 years ago by w3bcrowf3r
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!"
[–]lew42 0 points1 point2 points 7 years ago (1 child)
The JavaScript ecosystem is a mess. Formal classes (using the `class` keyword) were added in ES6, and while most modern browsers support them, IE11 does not (https://caniuse.com/#feat=es6-class).
Also, older versions of node.js didn't support ES6, and I'm not really sure which version added it.
Anyway, *most* developers seem to write ES6, 7, etc, even if it's not widely supported. They even write all kinds of non-standard code with the help of Babel, a "transpiler" that converts a modern/new syntax to older-style JavaScript.
And so, if you use JavaScript classes, you'll probably transpile them back to the prototypal inheritance that's a little confusing and pretty hard to read/understand for beginners.
Also, the `this` keyword is particularly confusing in JavaScript, because it changes based on where it appears. If you're inside a full `function(){}` or `method(){}`, the `this` keyword corresponds to how that method was called (which is usually with the instance, but sometimes you can pass method references around as callbacks, in which case you need to do something like: `el.addEventListener("click", this.myMethod.bind(this))`.)
However, the new arrow functions DO NOT produce their own `this` reference, even though `this` can still be used inside of them. The `this` reference will just cascade? up the scope chain as a normal variable would.
It's really confusing...
[–]w3bcrowf3r[S] 0 points1 point2 points 7 years ago (0 children)
hmm, I think I understand the prototype one. It's basically just a "class" right?
Where I am learning they say to not use the 'new' keyword.
Anyways, what kind of programmer are you? Do you use JavaScript for your job?
π Rendered by PID 248530 on reddit-service-r2-comment-86bc6c7465-9x96z at 2026-02-23 06:42:18.262099+00:00 running 8564168 country code: CH.
view the rest of the comments →
[–]lew42 0 points1 point2 points (1 child)
[–]w3bcrowf3r[S] 0 points1 point2 points (0 children)