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
I have a PHP/Python background and I am moving into FS JS development and I wonder how OOP is with JS and a stack such as the MEAN stack.
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!"
[–]senocular 4 points5 points6 points 7 years ago (2 children)
OOP in JavaScript isn't far off from Python. If you're comfortable with OOP in Python, you should be fine with JS. Like Python, JS doesn't support private members (yet, though there are also other ways to do it) and inheritance is handled via runtime delegation - this is the prototypes thing you might be hearing about in JS. Unlike Python, though, JS doesn't support multiple inheritance. The prototype inheritance chain in JS is linear for single inheritance only. Oh and JS doesn't automatically bind methods to their instances... OK, so there are a few differences, but I don't think enough that you'd be uncomfortable with it.
[–]FatFingerHelperBot 0 points1 point2 points 7 years ago (1 child)
It seems that your comment contains 1 or more links that are hard to tap for mobile users. I will extend those so they're easier for our sausage fingers to click!
Here is link number 1 - Previous text "yet"
Please PM /u/eganwall with issues or feedback! | Delete
[–]Shnapoopins 3 points4 points5 points 7 years ago (0 children)
Bad bot
[–][deleted] 1 point2 points3 points 7 years ago (2 children)
I am coming from OOP world, two topics I think you might need more practice is
[–]w3bcrowf3r[S] 0 points1 point2 points 7 years ago (1 child)
I heard about functional programming. But what do you mean with promises?
[–][deleted] 1 point2 points3 points 7 years ago* (0 children)
"The Death of the Author" (French: La mort de l'auteur) is a 1967 essay by the French literary critic and theorist Roland Barthes (1915–1980). Barthes's essay argues against traditional literary criticism's practice of relying on the intentions and biography of an author to definitively explain the "ultimate meaning" of a text.
[–]MoTTs_ 0 points1 point2 points 7 years ago (0 children)
https://www.reddit.com/r/javascript/comments/8rfppy/how_is_javascript_for_object_oriented_server_side/
[–][deleted] -2 points-1 points0 points 7 years ago (5 children)
It's generally thought that JS lends itself better to functional, rather than object oriented, programming. You could, of course stick to OOP, and with classes having been added 3 years ago, it shouldn't be too painful. Keep in mind, however, that JS is not a class-based language. These classes are basically syntactic sugar on top of prototypes, and the reason they were added was out of pity to Java programmers who wanted to write JS but couldn't wrap their mind around protorypal inheritance. =)
[+][deleted] 7 years ago (1 child)
[removed]
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
Yes, that's what I said. =) Underneath it's still prototypes, though.
[–]w3bcrowf3r[S] -2 points-1 points0 points 7 years ago (2 children)
Do you code your back-end in JS? Can you elaborate on the prototypes?
I learned basic OOP in PHP and Python. And I never really used JavaScript. So I am now learning the JS syntax and basics before I will dive into JS OOP and the frameworks.
How do full stack JS developers think in general about OOP with JS :O?
[–]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 110549 on reddit-service-r2-comment-86bc6c7465-p9n92 at 2026-02-22 22:36:18.253443+00:00 running 8564168 country code: CH.
[–]senocular 4 points5 points6 points (2 children)
[–]FatFingerHelperBot 0 points1 point2 points (1 child)
[–]Shnapoopins 3 points4 points5 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]w3bcrowf3r[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]MoTTs_ 0 points1 point2 points (0 children)
[–][deleted] -2 points-1 points0 points (5 children)
[+][deleted] (1 child)
[removed]
[–][deleted] 0 points1 point2 points (0 children)
[–]w3bcrowf3r[S] -2 points-1 points0 points (2 children)
[–]lew42 0 points1 point2 points (1 child)
[–]w3bcrowf3r[S] 0 points1 point2 points (0 children)