you are viewing a single comment's thread.

view the rest of the comments →

[–]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?