3 ms·
The newer class based IS the original prototype based. Class is literally just syntactic sugar on top of prototype inheritance. It was just added to help people
by irrational 4y ago
The newer class based IS the original prototype based. Class is literally just syntactic sugar on top of prototype inheritance. It was just added to help people coming from true OOP languages to feel comfortable. Notice, for instance, in Java the class acts as a blueprint for the object. You can’t have the object without the class. Not so in JS. The class is just window dressing and is not required at all.
- corrral 4y agoSure, but in practice most people ignore the prototypal features, especially if they're using the "class" keyword, so it may as well not be prototypal. Which is good, because the distinctly prototypal pieces are usually bad behaviors to rely on. The wrong kind of magic.
- ElectricalUnion 4y agoMost of this seems reasonably on point except for > true OOP languages Specifically the Java used as a example isn't exactly a "true OOP language" either; in a sense it's actually a very leaky imperative VM with implementation details like non-object Primitive Data Types and very visible and prominent imperative flow control structures. Javascript is much closer to an actual "true OOP language" as, unless you're dealing with bad/naive bindings to other stuff in C, it's very hard to even get a handle of a non-object.