Since ES6/ES2015 there is clearly a
In fact, let’s not take MDN’s word for it either. This is from the official ECMAScript specification:
Even though ECMAScript includes syntax for class definitions, ECMAScript objects are not fundamentally class-based such as those in C++, Smalltalk, or Java. Instead objects may be created in various ways including via a literal notation or via constructors which create objects and then execute code that initializes all or part of them by assigning initial values to their properties. Each constructor is a function that has a property named
prototypethat is used to implement prototype-based inheritance and shared properties.
Before we go any further, I should make a note on the use of the term “class” in this article series. While the general, more narrow concept of a class as such exists in many programming languages, the term is more often than not understood in the wider sense that is used in statically typed class-oriented languages such as Java, C# or C++, which includes related OOP concepts like inheritance, polymorphism and nominal types. More importantly, the introduction of
extends syntax in ES6 was both modelled on and motivated by familiarity to such languages, or at the very least is generally perceived as such, and it is from that perspective that these articles are written.
The subject at hand is a complex one and requires delving deep into various technical concepts, with many working examples to illustrate what is actually going on. It has therefore been broken up into several parts:
What does the