concept class declaration in category coffeescript

appears as: A class declaration, class declaration, The class declaration, class declarations
CoffeeScript in Action

This is an excerpt from Manning's book CoffeeScript in Action.

The class keyword, followed by a class name, begins the declaration of a class. A class declaration contains methods defining what an object created from the class does. The smallest valid definition of a class is just the class keyword with a name:

All variables are function-scoped so you’re surprised to see what happens when a new variable is assigned in the body of a class declaration:

Class variables are scoped to the class body. The class body has a variable scope like a function (as you’ll see later, when compiled to JavaScript the class declaration really is a function). They look a little bit like instance properties; be careful to notice the distinction.

It’s not going to be that easy. Agtron wants to change the special deals dynamically. You don’t know in advance what’s going to be discounted, so you can’t declare it in the class. You’ll need to extend the class dynamically. To learn how to extend a class dynamically, you need to learn how classes really work. It’s finally time to see the JavaScript that the CoffeeScript compiler creates from a class declaration.