Skip to Main Content
Hands-On Functional Programming with TypeScript
book

Hands-On Functional Programming with TypeScript

by Remo H. Jansen
January 2019
Beginner content levelBeginner
210 pages
4h 47m
English
Packt Publishing
Content preview from Hands-On Functional Programming with TypeScript

Prototypal inheritance

You might be wondering how the extends keyword works. Let's create a new TypeScript class, which inherits from the Person class, to understand it:

class SuperHero extends Person {    public superpower: string;    public constructor(        name: string,        surname: string,        superpower: string    ) {        super(name, surname);        this.superpower = superpower;    }    public userSuperPower() {        return 'I'm using my ${this.superpower}';    }}

The preceding class is named SuperHero and extends the Person class. It has one additional attribute (superpower) and method (useSuperPower). 

We need to compile the previous code snippet into JavaScript code so we can examine how inheritance is implemented at runtime. The compiler will generate a polyfill function named ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Functional Programming in JavaScript

Functional Programming in JavaScript

Luis Atencio
TypeScript Quickly

TypeScript Quickly

Yakov Fain, Anton Moiseev
Functional Programming in Kotlin

Functional Programming in Kotlin

Runar Bjarnason, Paul Chiusano, Marco Vermeulen

Publisher Resources

ISBN: 9781788831437Supplemental Content