DZone

Introduced by the ECMAScript 2015 specifications, the class construct has become part of the official JavaScript syntax. This construct has been enthusiastically welcomed by many developers. Indeed, it has been considered a sign of the formalization of various attempts to simulate classes, inheritance, and other object-oriented features offered for several years by many libraries, such as PrototypeExtJSDojoBackboneEmber, and others. TypeScript itself was born with the aim of bringing class-based object-oriented programming to the JavaScript language. However, the class construct may lead to serious misconceptions about the object-oriented nature of JavaScript. Let’s analyze why.

A Convenient Construct

Using the class construct is very handy. Just take a look at the following code to define the Animal class:

Source: DZone