O'Reilly logo

Programming in CoffeeScript by Mark Bates

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

2. The Basics

Now that we’ve covered the boring stuff, like compiling and executing your CoffeeScript, we will start covering how to actually write it. Let’s dive right in.

In this chapter we are going to examine the syntax of CoffeeScript. We’ll look at punctuation, scope, variables, and a few other choice bits.

Syntax

Much of CoffeeScript’s press has been due to its syntax, in particular its lack of punctuation. Punctuation such as curly braces and semicolons are extinct in the world of CoffeeScript, and parentheses are an endangered species.

To illustrate this point, let’s take a look at a bit of JavaScript that most of you might be familiar with. Here is a piece of jQuery code to make a remote AJAX request and do some work with the results: ...

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