Inheritance

Inheritance is a powerful concept that many modern programming languages use extensively. JavaScript has never embraced it wholeheartedly, in large part because implementing it has always been slightly awkward and error-prone due to some omissions in the JavaScript language. Thankfully, CoffeeScript patches up those holes and makes inheritance a first-class experience again.

Note

Inheritance is used to define is-a relationships, such as "an Apple is a type of Fruit". Child classes (like Apple) inherit behavior from parent classes (like Fruit), while often adding more behavior or selectively modifying existing behavior. Inheritance can be chained through several generations, and a child inherits behavior from all of its ancestors, with ...

Get CoffeeScript Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.