Inheritance in ES6

This lesson introduces the keywords extends and super and explains their use in implementing inheritance in JavaScript.

We'll cover the following

In the previous chapter, the implementation of class in the ES6 version of JavaScript was discussed. The version introduced the keyword class used to define a class.

Now let’s learn how to implement inheritance in ES6 version of JavaScript.

Syntax

The underlying concept regarding the implementation of inheritance is the same in both versions, ES5 and ES6; however, the latter provides a cleaner syntax as well as some new keywords that can be used during the implementation.

The ES6 version uses the keyword extends which creates a class that is the child of another class.

The following is the syntax used in ES6:

Create a free account to access the full course.

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