With ES6 you can inherit from built-in classes like Array, String, RegEx, etc.,

In this way you can create data structures like stacks, queues, or any other linked-list structures from buildin class.

The following code implements a ReversedString data type by extending String built-in class:

class ReversedString extends String { 
        print() { 
                return this.split('').reverse().join(''); 


const str = new ReversedString("Awesome"); 

// emosewA 

Related Topic