Implementing Classes
This lesson introduces the ES6 version of classes, their syntax, and teaches us how to create new object instances using a class.
We'll cover the following
The ES6 version of JavaScript offers some new features as well as improvements. One of those improvements was the introduction of the keyword class
.
Constructor functions are used in the ES5 version to implement the concept of classes. However, in the ES6 version, the class
keyword is used, which cleans up the syntax for implementing the same concept, thus making it easier to understand.
What Is a Class?
There is no concept of classes in the ES5 version. In ES5, a blueprint containing all properties and methods which could then be inherited by the object instances created from that blueprint was needed. This saves us the time and effort to create separate object literals. The ES6 version introduces the class
keyword to create classes that are used to implement this functionality. The classes created then become the blueprints from which the objects inherit their properties.
Get hands-on with 1400+ tech skills courses.