Implementing Classes

This lesson introduces the ES6 version of classes, their syntax and also teaches how to create new object instances using a class.

As discussed in the first chapter, the ES6 version of JavaScript offers some new features as well as improvements. One of those improvements that were discussed was the introduction of the keyword class.

In the previous chapter, we discussed function constructors, which 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 hence making it easier to understand.

What Is a Class? #

We discussed that in the ES5 version there is no concept of classes. What we needed was a blueprint containing all properties and methods which could then be inherited by the object instances created from that blueprint. This saves us the time and effort to create separate object literals. The ES6 version introduces the class keyword to create classes which are used to implement this functionality. The classes created then become the blueprints from which the objects inherit their properties.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy