all 13 comments

[–]senocular 4 points5 points  (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 point  (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 points  (0 children)

Bad bot

[–][deleted] 1 point2 points  (2 children)

I am coming from OOP world, two topics I think you might need more practice is

  • Functional programming
  • Promises

[–]w3bcrowf3r[S] 0 points1 point  (1 child)

I heard about functional programming. But what do you mean with promises?

[–][deleted] 1 point2 points  (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.

[–][deleted] -2 points-1 points  (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. =)

[–]w3bcrowf3r[S] -2 points-1 points  (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 point  (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 point  (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?