Easy Tutorial
❮ Js Scope Js Window Location ❯

JavaScript Class extends Keyword

JavaScript Class


Example

Example

The following example creates a class "tutorialpro" that inherits from the "Site" class:


Definition and Usage

The extends keyword is used to create a class which is a child of another class.

A child class inherits all the methods of another class.

Inheritance is useful for code reusability: reuse properties and methods of an existing class when you create a new class.

The super() method refers to the parent class.

By calling the super() method in the constructor method, we call the parent's constructor method and gets access to the parent's properties and methods.

Syntax

class childClass extends parentClass

Technical Details

| JavaScript Version: | ECMAScript 2015 (ES6) |

Browser Support

extends is an ECMAScript6 (ES6) feature.

ES6 (JavaScript 2015) is supported in all modern browsers.

Chrome Edge Firefox Safari Opera
Yes Yes Yes Yes Yes

Internet Explorer 11 or older versions of IE do not support the extends keyword.


JavaScript Class

❮ Js Scope Js Window Location ❯