O'Reilly logo

CoffeeScript Application Development Cookbook by Mike Hatfield

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with classes

Traditional classes do not exist in JavaScript. They can be very useful in decomposing your code into reusable component-like blocks. This is especially true if you are used to working with classes in other languages.

CoffeeScript classes are compiled into constructor functions that allow us to instantiate JavaScript objects. Using CoffeeScript classes makes use of best practices to define objects by keeping private variables private and making proper use of function prototypes.

In this section, we will look at defining classes with properties and methods, using class inheritance, and some of the hurdles we can run into when using CoffeeScript classes.

Defining classes

Creating a class involves using the class CoffeeScript keyword ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required