CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.

The golden rule of CoffeeScript is: “It’s just JavaScript.” The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. You can use any existing JavaScript library seamlessly from CoffeeScript (and vice-versa). The compiled output is readable, pretty-printed, and tends to run as fast or faster than the equivalent handwritten JavaScript.

Latest Version: 2.0.0-beta1

npm install -g coffeescript@next


CoffeeScript on the topleft, compiled JavaScript output on the bottomright. The CoffeeScript is editable!

CoffeeScript 2

Why CoffeeScript When There’s ES2015+?

CoffeeScript introduced many new features to the JavaScript world, such as => and destructuring and classes. We are happy that ECMA has seen their utility and adopted them into ECMAScript.

CoffeeScript’s intent, however, was never to be a superset of JavaScript. One of the guiding principles of CoffeeScript has been simplicity: not just removing JavaScript’s “bad parts,” but providing a cleaner, terser syntax that uses less punctuation and enforces indentation, to make code easier to read and reason about. Increased clarity leads to increased quality, and fewer bugs. This benefit of CoffeeScript remains, even in an ES2015+ world.

ES2015+ Output

CoffeeScript 2 supports many of the latest ES2015+ features, output using ES2015+ syntax. If you’re looking for a single tool that takes CoffeeScript input and generates JavaScript output that runs in any JavaScript runtime, assuming you opt out of certain newer features, stick to the CoffeeScript 1.x branch. CoffeeScript 2 breaks compatibility with certain CoffeeScript 1.x features in order to conform with the ES2015+ specifications, and generate more idiomatic output (a CoffeeScript => becomes an ES =>; a CoffeeScript class becomes an ES class; and so on).

Since the CoffeeScript 2 compiler outputs ES2015+ syntax, it is your responsibility to either ensure that your target JavaScript runtime(s) support all these features, or that you pass the output through another transpiler like Babel, Rollup or Traceur Compiler. In general, CoffeeScript 2’s output is supported as is by Node.js 7.6+, except for modules which require transpilation.

There are many great task runners for setting up JavaScript build chains, such as Gulp, Webpack, Grunt and Broccoli. If you’re looking for a very minimal solution to get started, you can use babel-preset-env and the command line:

npm install --global coffeescript@next
npm install --save-dev coffeescript@next babel-cli babel-preset-env
coffee -p *.coffee | babel --presets env > app.js


The command-line version of coffee is available as a Node.js utility. The core compiler however, does not depend on Node, and can be run in any JavaScript environment, or in the browser (see Try CoffeeScript).

To install, first make sure you have a working copy of the latest stable version of Node.js. You can then install CoffeeScript globally with npm:

npm install --global coffeescript@next

When you need CoffeeScript as a dependency of a project, within that project’s folder you can install it locally:

npm install --save coffeescript@next


Once installed, you should have access to the coffee command, which can execute scripts, compile .coffee files into .js, and provide an interactive REPL. The coffee command takes the following options:

Option Description
-c, --compile Compile a .coffee script into a .js JavaScript file of the same name.
-m, --map Generate source maps alongside the compiled JavaScript files. Adds sourceMappingURL directives to the JavaScript as well.
-M, --inline-map Just like --map, but include the source map directly in the compiled JavaScript files, rather than in a separate file.
-i, --interactive Launch an interactive CoffeeScript session to try short snippets. Identical to calling coffee with no arguments.
-o, --output [DIR] Write out all compiled JavaScript files into the specified directory. Use in conjunction with --compile or --watch.
-w, --watch Watch files for changes, rerunning the specified command when any file is updated.
-p, --print Instead of writing out the JavaScript as a file, print it directly to stdout.
-s, --stdio Pipe in CoffeeScript to STDIN and get back JavaScript over STDOUT. Good for use with processes written in other languages. An example:
cat src/ | coffee -sc
-l, --literate Parses the code as Literate CoffeeScript. You only need to specify this when passing in code directly over stdio, or using some sort of extension-less file name.
-e, --eval Compile and print a little snippet of CoffeeScript directly from the command line. For example:
coffee -e "console.log num for num in [10..1]"
-r, --require [MODULE] require() the given module before starting the REPL or evaluating the code given with the --eval flag.
-b, --bare Compile the JavaScript without the top-level function safety wrapper.
-t, --tokens Instead of parsing the CoffeeScript, just lex it, and print out the token stream. Used for debugging the compiler.
-n, --nodes Instead of compiling the CoffeeScript, just lex and parse it, and print out the parse tree. Used for debugging the compiler.
--nodejs The node executable has some useful options you can set, such as --debug, --debug-brk, --max-stack-size, and --expose-gc. Use this flag to forward options directly to Node.js. To pass multiple flags, use --nodejs multiple times.
--no-header Suppress the “Generated by CoffeeScript” header.


  • Compile a directory tree of .coffee files in src into a parallel tree of .js files in lib:
    coffee --compile --output lib/ src/
  • Watch a file for changes, and recompile it every time the file is saved:
    coffee --watch --compile
  • Concatenate a list of files into a single script:
    coffee --join project.js --compile src/*.coffee
  • Print out the compiled JS from a one-liner:
    coffee -bpe "alert i for i in [0..10]"
  • All together now, watch and recompile an entire project as you work on it:
    coffee -o lib/ -cw src/
  • Start the CoffeeScript REPL (Ctrl-D to exit, Ctrl-Vfor multi-line):

Language Reference

This reference is structured so that it can be read from top to bottom, if you like. Later sections use ideas and syntax previously introduced. Familiarity with JavaScript is assumed. In all of the following examples, the source CoffeeScript is provided on the left, and the direct compilation into JavaScript is on the right.

Many of the examples can be run (where it makes sense) by pressing the button on the right. The CoffeeScript on the left is editable, and the JavaScript will update as you edit.

First, the basics: CoffeeScript uses significant whitespace to delimit blocks of code. You don’t need to use semicolons ; to terminate expressions, ending the line will do just as well (although semicolons can still be used to fit multiple expressions onto a single line). Instead of using curly braces { } to surround blocks of code in functions, if-statements, switch, and try/catch, use indentation.

You don’t need to use parentheses to invoke a function if you’re passing arguments. The implicit call wraps forward to the end of the line or block expression.
console.log sys.inspect objectconsole.log(sys.inspect(object));


Functions are defined by an optional list of parameters in parentheses, an arrow, and the function body. The empty function looks like this: ->

Functions may also have default values for arguments, which will be used if the incoming argument is missing (undefined).


Like JavaScript and many other languages, CoffeeScript supports strings as delimited by the " or ' characters. CoffeeScript also supports string interpolation within "-quoted strings, using #{ … }. Single-quoted strings are literal. You may even use interpolation in object keys.

Multiline strings are allowed in CoffeeScript. Lines are joined by a single space unless they end with a backslash. Indentation is ignored.

Block strings, delimited by """ or ''', can be used to hold formatted or indentation-sensitive text (or, if you just don’t feel like escaping quotes and apostrophes). The indentation level that begins the block is maintained throughout, so you can keep it all aligned with the body of your code.

Double-quoted block strings, like other double-quoted strings, allow interpolation.

Objects and Arrays

The CoffeeScript literals for objects and arrays look very similar to their JavaScript cousins. When each property is listed on its own line, the commas are optional. Objects may be created using indentation instead of explicit braces, similar to YAML.

In JavaScript, you can’t use reserved words, like class, as properties of an object, without quoting them as strings. CoffeeScript notices reserved words used as keys in objects and quotes them for you, so you don’t have to worry about it (say, when using jQuery).

CoffeeScript has a shortcut for creating objects when you want the key to be set with a variable of the same name.


In CoffeeScript, comments are denoted by the # character. Everything from a # to the end of the line is ignored by the compiler, and will be excluded from the JavaScript output.

Sometimes you’d like to pass a block comment through to the generated JavaScript. For example, when you need to embed a licensing header at the top of a file. Block comments, which mirror the syntax for block strings, are preserved in the generated output.

Lexical Scoping and Variable Safety

The CoffeeScript compiler takes care to make sure that all of your variables are properly declared within lexical scope — you never need to write var yourself.

Notice how all of the variable declarations have been pushed up to the top of the closest scope, the first time they appear. outer is not redeclared within the inner function, because it’s already in scope; inner within the function, on the other hand, should not be able to change the value of the external variable of the same name, and therefore has a declaration of its own.

This behavior is effectively identical to Ruby’s scope for local variables. Because you don’t have direct access to the var keyword, it’s impossible to shadow an outer variable on purpose, you may only refer to it. So be careful that you’re not reusing the name of an external variable accidentally, if you’re writing a deeply nested function.

Although suppressed within this documentation for clarity, all CoffeeScript output is wrapped in an anonymous function: (function(){ … })(); This safety wrapper, combined with the automatic generation of the var keyword, make it exceedingly difficult to pollute the global namespace by accident.

If you’d like to create top-level variables for other scripts to use, attach them as properties on window; attach them as properties on the exports object in CommonJS; or use an export statement. If you’re targeting both CommonJS and the browser, the existential operator (covered below), gives you a reliable way to figure out where to add them: exports ? this

If, Else, Unless, and Conditional Assignment

If/else statements can be written without the use of parentheses and curly brackets. As with functions and other block expressions, multi-line conditionals are delimited by indentation. There’s also a handy postfix form, with the if or unless at the end.

CoffeeScript can compile if statements into JavaScript expressions, using the ternary operator when possible, and closure wrapping otherwise. There is no explicit ternary statement in CoffeeScript — you simply use a regular if statement on a single line.


The JavaScript arguments object is a useful way to work with functions that accept variable numbers of arguments. CoffeeScript provides splats ..., both for function definition as well as invocation, making variable numbers of arguments a little bit more palatable.

Loops and Comprehensions

Most of the loops you’ll write in CoffeeScript will be comprehensions over arrays, objects, and ranges. Comprehensions replace (and compile into) for loops, with optional guard clauses and the value of the current array index. Unlike for loops, array comprehensions are expressions, and can be returned and assigned.

Comprehensions should be able to handle most places where you otherwise would use a loop, each/forEach, map, or select/filter, for example:
shortNames = (name for name in list when name.length < 5)
If you know the start and end of your loop, or would like to step through in fixed-size increments, you can use a range to specify the start and end of your comprehension.

Note how because we are assigning the value of the comprehensions to a variable in the example above, CoffeeScript is collecting the result of each iteration into an array. Sometimes functions end with loops that are intended to run only for their side-effects. Be careful that you’re not accidentally returning the results of the comprehension in these cases, by adding a meaningful return value — like true — or null, to the bottom of your function.

To step through a range comprehension in fixed-size chunks, use by, for example: evens = (x for x in [0..10] by 2)

If you don’t need the current iteration value you may omit it: browser.closeCurrentTab() for [0...count]

Comprehensions can also be used to iterate over the keys and values in an object. Use of to signal comprehension over the properties of an object instead of the values in an array.

If you would like to iterate over just the keys that are defined on the object itself, by adding a hasOwnProperty check to avoid properties that may be inherited from the prototype, use for own key, value of object.

To iterate a generator function, use from. See Generator Functions.

The only low-level loop that CoffeeScript provides is the while loop. The main difference from JavaScript is that the while loop can be used as an expression, returning an array containing the result of each iteration through the loop.

For readability, the until keyword is equivalent to while not, and the loop keyword is equivalent to while true.

When using a JavaScript loop to generate functions, it’s common to insert a closure wrapper in order to ensure that loop variables are closed over, and all the generated functions don’t just share the final values. CoffeeScript provides the do keyword, which immediately invokes a passed function, forwarding any arguments.

Array Slicing and Splicing with Ranges

Ranges can also be used to extract slices of arrays. With two dots (3..6), the range is inclusive (3, 4, 5, 6); with three dots (3...6), the range excludes the end (3, 4, 5). Slices indices have useful defaults. An omitted first index defaults to zero and an omitted second index defaults to the size of the array.

The same syntax can be used with assignment to replace a segment of an array with new values, splicing it.

Note that JavaScript strings are immutable, and can’t be spliced.

Everything is an Expression (at least, as much as possible)

You might have noticed how even though we don’t add return statements to CoffeeScript functions, they nonetheless return their final value. The CoffeeScript compiler tries to make sure that all statements in the language can be used as expressions. Watch how the return gets pushed down into each possible branch of execution in the function below.

Even though functions will always return their final value, it’s both possible and encouraged to return early from a function body writing out the explicit return (return value), when you know that you’re done.

Because variable declarations occur at the top of scope, assignment can be used within expressions, even for variables that haven’t been seen before:

Things that would otherwise be statements in JavaScript, when used as part of an expression in CoffeeScript, are converted into expressions by wrapping them in a closure. This lets you do useful things, like assign the result of a comprehension to a variable:

As well as silly things, like passing a try/catch statement directly into a function call:

There are a handful of statements in JavaScript that can’t be meaningfully converted into expressions, namely break, continue, and return. If you make use of them within a block of code, CoffeeScript won’t try to perform the conversion.

Operators and Aliases

Because the == operator frequently causes undesirable coercion, is intransitive, and has a different meaning than in other languages, CoffeeScript compiles == into ===, and != into !==. In addition, is compiles into ===, and isnt into !==.

You can use not as an alias for !.

For logic, and compiles to &&, and or into ||.

Instead of a newline or semicolon, then can be used to separate conditions from expressions, in while, if/else, and switch/when statements.

As in YAML, on and yes are the same as boolean true, while off and no are boolean false.

unless can be used as the inverse of if.

As a shortcut for, you can use @property.

You can use in to test for array presence, and of to test for JavaScript object-key presence.

To simplify math expressions, ** can be used for exponentiation and // performs integer division. % works just like in JavaScript, while %% provides “dividend dependent modulo”:

All together now:

CoffeeScript JavaScript
is ===
isnt !==
not !
and &&
or ||
true, yes, on true
false, no, off false
@, this this
of in
in no JS equivalent
a ** b Math.pow(a, b)
a // b Math.floor(a / b)
a %% b (a % b + b) % b

The Existential Operator

It’s a little difficult to check for the existence of a variable in JavaScript. if (variable) … comes close, but fails for zero, the empty string, and false. CoffeeScript’s existential operator ? returns true unless a variable is null or undefined, which makes it analogous to Ruby’s nil?

It can also be used for safer conditional assignment than ||= provides, for cases where you may be handling numbers or strings.

The accessor variant of the existential operator ?. can be used to soak up null references in a chain of properties. Use it instead of the dot accessor . in cases where the base value may be null or undefined. If all of the properties exist then you’ll get the expected result, if the chain is broken, undefined is returned instead of the TypeError that would be raised otherwise.

Soaking up nulls is similar to Ruby’s andand gem, and to the safe navigation operator in Groovy.


CoffeeScript 1 provided the class and extends keywords as syntactic sugar for working with prototypal functions. With ES2015, JavaScript has adopted those keywords; so CoffeeScript 2 compiles its class and extends keywords to ES2015 classes.

Static methods can be defined using @ before the method name:

Finally, class definitions are blocks of executable code, which make for interesting metaprogramming possibilities. In the context of a class definition, this is the class object itself; therefore, you can assign static properties by using @property: value.

Prototypal Inheritance

In addition to supporting ES2015 classes, CoffeeScript provides a few shortcuts for working with prototypes. The extends operator can be used to create an inheritance chain between any pair of constructor functions, and :: gives you quick access to an object’s prototype:

Destructuring Assignment

Just like JavaScript (since ES2015), CoffeeScript has destructuring assignment syntax. When you assign an array or object literal to a value, CoffeeScript breaks up and matches both sides against each other, assigning the values on the right to the variables on the left. In the simplest case, it can be used for parallel assignment:

But it’s also helpful for dealing with functions that return multiple values.

Destructuring assignment can be used with any depth of array and object nesting, to help pull out deeply nested properties.

Destructuring assignment can even be combined with splats.

Expansion can be used to retrieve elements from the end of an array without having to assign the rest of its values. It works in function parameter lists as well.

Destructuring assignment is also useful when combined with class constructors to assign properties to your instance from an options object passed to the constructor.

The above example also demonstrates that if properties are missing in the destructured object or array, you can, just like in JavaScript, provide defaults. The difference with JavaScript is that CoffeeScript, as always, treats both null and undefined the same.

Function Modifiers

In JavaScript, the this keyword is dynamically scoped to mean the object that the current function is attached to. If you pass a function as a callback or attach it to a different object, the original value of this will be lost. If you’re not familiar with this behavior, this Digital Web article gives a good overview of the quirks.

The fat arrow => can be used to both define a function, and to bind it to the current value of this, right on the spot. This is helpful when using callback-based libraries like Prototype or jQuery, for creating iterator functions to pass to each, or event-handler functions to use with on. Functions created with the fat arrow are able to access properties of the this where they’re defined.

If we had used -> in the callback above, @customer would have referred to the undefined “customer” property of the DOM element, and trying to call purchase() on it would have raised an exception.

When used in a class definition, methods declared with the fat arrow will be automatically bound to each instance of the class when the instance is constructed.

CoffeeScript also supports generator functions and async functions through the yield and await keywords respectively. There’s no function*(){} or async function(){} nonsense — a generator in CoffeeScript is simply a function that yields, and an async function in CoffeeScript is simply a function that awaits.

yield* is called yield from, and yield return may be used if you need to force a generator that doesn’t yield.

You can iterate over a generator function using for…from.

Similar to how yield return forces a generator, await return may be used to force a function to be async.


Switch statements in JavaScript are a bit awkward. You need to remember to break at the end of every case statement to avoid accidentally falling through to the default case. CoffeeScript prevents accidental fall-through, and can convert the switch into a returnable, assignable expression. The format is: switch condition, when clauses, else the default case.

As in Ruby, switch statements in CoffeeScript can take multiple values for each when clause. If any of the values match, the clause runs.

Switch statements can also be used without a control expression, turning them in to a cleaner alternative to if/else chains.


Try-expressions have the same semantics as try-statements in JavaScript, though in CoffeeScript, you may omit both the catch and finally parts. The catch part may also omit the error parameter if it is not needed.

Chained Comparisons

CoffeeScript borrows chained comparisons from Python — making it easy to test if a value falls within a certain range.

Block Regular Expressions

Similar to block strings and comments, CoffeeScript supports block regexes — extended regular expressions that ignore internal whitespace and can contain comments and interpolation. Modeled after Perl’s /x modifier, CoffeeScript’s block regexes are delimited by /// and go a long way towards making complex regular expressions readable. To quote from the CoffeeScript source:

Tagged Template Literals

CoffeeScript supports ES2015 tagged template literals, which enable customized string interpolation. If you immediately prefix a string with a function name (no space between the two), CoffeeScript will output this “function plus string” combination as an ES2015 tagged template literal, which will behave accordingly: the function is called, with the parameters being the input text and expression parts that make up the interpolated string. The function can then assemble these parts into an output string, providing custom string interpolation.


ES2015 modules are supported in CoffeeScript, with very similar import and export syntax:

Note that the CoffeeScript compiler does not resolve modules; writing an import or export statement in CoffeeScript will produce an import or export statement in the resulting output. It is your responsibility attach another transpiler, such as Traceur Compiler, Babel or Rollup, to convert this ES2015 syntax into code that will work in your target runtimes.

Also note that any file with an import or export statement will be output without a top-level function safety wrapper; in other words, importing or exporting modules will automatically trigger bare mode for that file. This is because per the ES2015 spec, import or export statements must occur at the topmost scope.

Embedded JavaScript

Hopefully, you’ll never need to use it, but if you ever need to intersperse snippets of JavaScript within your CoffeeScript, you can use backticks to pass it straight through.

Escape backticks with backslashes: \`​ becomes `​.

Escape backslashes before backticks with more backslashes: \\\`​ becomes \`​.

You can also embed blocks of JavaScript using triple backticks. That’s easier than escaping backticks, if you need them inside your JavaScript block.

Unsupported ECMAScript Features

There are a few ECMAScript features that CoffeeScript intentionally doesn’t support.

let and const: Block-Scoped and Reassignment-Protected Variables

When CoffeeScript was designed, var was intentionally omitted. This was to spare developers the mental housekeeping of needing to worry about variable declaration (var foo) as opposed to variable assignment (foo = 1). The CoffeeScript compiler automatically takes care of declaration for you, by generating var statements at the top of every function scope. This makes it impossible to accidentally declare a global variable.

let and const add a useful ability to JavaScript in that you can use them to declare variables within a block scope, for example within an if statement body or a for loop body, whereas var always declares variables in the scope of an entire function. When CoffeeScript 2 was designed, there was much discussion of whether this functionality was useful enough to outweigh the simplicity offered by never needing to consider variable declaration in CoffeeScript. In the end, it was decided that the simplicity was more valued. In CoffeeScript there remains only one type of variable.

Keep in mind that const only protects you from reassigning a variable; it doesn’t prevent the variable’s value from changing, the way constants usually do in other languages:

const obj = {foo: 'bar'}; = 'baz'; // Allowed!
obj = {}; // Throws error

get and set Keyword Shorthand Syntax

get and set, as keywords preceding functions or class methods, are intentionally unimplemented in CoffeeScript.

This is to avoid grammatical ambiguity, since in CoffeeScript such a construct looks identical to a function call (e.g. get(function foo() {})); and because there is an alternate syntax that is slightly more verbose but just as effective:

Literate CoffeeScript

Besides being used as an ordinary programming language, CoffeeScript may also be written in “literate” mode. If you name your file with a .litcoffee extension, you can write it as a Markdown document — a document that also happens to be executable CoffeeScript code. The compiler will treat any indented blocks (Markdown’s way of indicating source code) as code, and ignore the rest as comments.

Just for kicks, a little bit of the compiler is currently implemented in this fashion: See it as a document, raw, and properly highlighted in a text editor.

Source Maps

CoffeeScript includes support for generating source maps, a way to tell your JavaScript engine what part of your CoffeeScript program matches up with the code being evaluated. Browsers that support it can automatically use source maps to show your original source code in the debugger. To generate source maps alongside your JavaScript files, pass the --map or -m flag to the compiler.

For a full introduction to source maps, how they work, and how to hook them up in your browser, read the HTML5 Tutorial.

Cake, and Cakefiles

CoffeeScript includes a (very) simple build system similar to Make and Rake. Naturally, it’s called Cake, and is used for the tasks that build and test the CoffeeScript language itself. Tasks are defined in a file named Cakefile, and can be invoked by running cake [task] from within the directory. To print a list of all the tasks and options, just type cake.

Task definitions are written in CoffeeScript, so you can put arbitrary code in your Cakefile. Define a task with a name, a long description, and the function to invoke when the task is run. If your task takes a command-line option, you can define the option with short and long flags, and it will be made available in the options object. Here’s a task that uses the Node.js API to rebuild CoffeeScript’s parser:

If you need to invoke one task before another — for example, running build before test, you can use the invoke function: invoke 'build'. Cake tasks are a minimal way to expose your CoffeeScript functions to the command line, so don’t expect any fanciness built-in. If you need dependencies, or async callbacks, it’s best to put them in your code itself — not the cake task.

"text/coffeescript" Script Tags

While it’s not recommended for serious use, CoffeeScripts may be included directly within the browser using <script type="text/coffeescript"> tags. The source includes a compressed and minified version of the compiler (Download current version here, 51k when gzipped) as docs/v2/browser-compiler/coffeescript.js. Include this file on a page with inline CoffeeScript tags, and it will compile and evaluate them in order.

In fact, the little bit of glue script that runs Try CoffeeScript, as well as the code examples and other interactive parts of this site, is implemented in just this way. View source and look at the bottom of the page to see the example. Including the script also gives you access to CoffeeScript.compile() so you can pop open your JavaScript console and try compiling some strings.

The usual caveats about CoffeeScript apply — your inline scripts will run within a closure wrapper, so if you want to expose global variables or functions, attach them to the window object.


  • CoffeeScript on GitHub
  • CoffeeScript Issues
    Bug reports, feature proposals, and ideas for changes to the language belong here.
  • CoffeeScript Google Group
    If you’d like to ask a question, the mailing list is a good place to get help.
  • The CoffeeScript Wiki
    If you’ve ever learned a neat CoffeeScript tip or trick, or ran into a gotcha — share it on the wiki. The wiki also serves as a directory of handy text editor extensions, web framework plugins, and general CoffeeScript build tools.
  • The FAQ
    Perhaps your CoffeeScript-related question has been asked before. Check the FAQ first.
  • JS2Coffee
    Is a very well done reverse JavaScript-to-CoffeeScript compiler. It’s not going to be perfect (infer what your JavaScript classes are, when you need bound functions, and so on…) — but it’s a great starting point for converting simple scripts.
  • High-Rez Logo
    The CoffeeScript logo is available in SVG for use in presentations.


There are a number of excellent resources to help you get started with CoffeeScript, some of which are freely available online.


  • A Sip of CoffeeScript is a Code School Course which combines 6 screencasts with in-browser coding to make learning fun. The first level is free to try out.
  • Meet CoffeeScript is a 75-minute long screencast by PeepCode, now PluralSight. Highly memorable for its animations which demonstrate transforming CoffeeScript into the equivalent JS.
  • If you’re looking for less of a time commitment, RailsCasts’ CoffeeScript Basics should have you covered, hitting all of the important notes about CoffeeScript in 11 minutes.


The best list of open-source CoffeeScript examples can be found on GitHub. But just to throw out a few more:

  • GitHub’s Hubot, a friendly IRC robot that can perform any number of useful and useless tasks.
  • sstephenson’s Pow, a zero-configuration Rack server, with comprehensive annotated source.
  • technoweenie’s Coffee-Resque, a port of Resque for Node.js.
  • stephank’s Orona, a remake of the Bolo tank game for modern browsers.
  • GitHub’s Atom, a hackable text editor built on web technologies.
  • Basecamp’s Trix, a rich text editor for web apps.

Web Chat (IRC)

Quick help and advice can often be found in the CoffeeScript IRC room #coffeescript on, which you can join via your web browser.

Annotated Source

You can browse the CoffeeScript 2.0.0-beta1 source in readable, annotated form here. You can also jump directly to a particular source file:


Contributions are welcome! Feel free to fork the repo and submit a pull request.

Some features of ECMAScript are intentionally unsupported. Please review both the open and closed issues on GitHub to see if the feature you’re looking for has already been discussed. As a general rule, we don’t support ECMAScript syntax for features that aren’t yet finalized (at Stage 4 in the proposal approval process).

For more resources on adding to CoffeeScript, please see the Wiki, especially How The Parser Works.

There are several things you can do to increase your odds of having your pull request accepted:

  • Create tests! Any pull request should probably include basic tests to verify you didn’t break anything, or future changes won’t break your code.
  • Follow the style of the rest of the CoffeeScript codebase.
  • Ensure any ECMAScript syntax is mature (at Stage 4), with no further potential changes.
  • Add only features that have broad utility, rather than a feature aimed at a specific use case or framework.

Of course, it’s entirely possible that you have a great addition, but it doesn’t fit within these constraints. Feel free to roll your own solution; you will have plenty of company.

Breaking Changes From CoffeeScript 1.x to 2

CoffeeScript 2 aims to output as much idiomatic ES2015+ syntax as possible with as few breaking changes from CoffeeScript 1.x as possible. Some breaking changes, unfortunately, were unavoidable.

Default values for function parameters and destructured elements

Per the ES2015 spec regarding function default parameters and destructuring default values, default values are only applied when a value is missing or undefined. In CoffeeScript 1.x, the default value would be applied in those cases but also if the value was null.

Bound generator functions

Bound generator functions, a.k.a. generator arrow functions, aren’t allowed in ECMAScript. You can write function* or =>, but not both. Therefore, CoffeeScript code like this:

f = => yield this
# Throws a compiler error

Needs to be rewritten the old-fashioned way:

Classes are compiled to ES2015 classes

ES2015 classes and their methods have some restrictions beyond those on regular functions.

Class constructors can’t be invoked without new:

# Throws a TypeError at runtime

Derived (extended) class constructors cannot use this before calling super:

class B extends A
  constructor: -> this
  # Throws a compiler error

Class methods can’t be used with new (uncommon):

class Namespace
  @Klass = ->
new Namespace.Klass
# Throws a TypeError at runtime

Bare super

Due to a syntax clash with super with accessors, bare super no longer compiles to a super call forwarding all arguments.

class B extends A
  foo: -> super
  # Throws a compiler error

Arguments can be forwarded explicitly using splats:

Or if you know that the parent function doesn’t require arguments, just call super():

super in non-class methods

In CoffeeScript 1.x it is possible to use super in more than just class methods, such as in manually prototype-assigned functions:

A = ->
B = ->
B extends A = -> super arguments...
# Throws a compiler error

Due to the switch to ES2015 super, this is no longer supported. The above case could be refactored to:


Dynamic class keys exclude executable class scope

Due to the hoisting required to compile to ES2015 classes, dynamic keys in class methods can’t use values from the executable class body unless the methods are assigned in prototype style.

class A
  name = 'method'
  "#{name}": ->   # This method will be named 'undefined'
  @::[name] = ->  # This will work; assigns to `A.prototype.method`

Literate CoffeeScript now parsed by a Markdown library

The CoffeeScript 1.x implementation of Literate CoffeeScript relies on indentation to tell apart code blocks from documentation, and as such it can get confused by Markdown features that also use indentation like lists. In CoffeeScript 2 this has been refactored to now use Markdown-It to detect Markdown sections rather than just looking at indentation. The only significant difference is that now if you want to include a code block in documentation, as opposed to the compiler recognizing that code block as code, it must have at least one line fully unindented. Wrapping it in HTML tags is no longer sufficient.

Code blocks interspersed with lists may need to be refactored. In general, code blocks should be separated by a blank line between documentation, and should maintain a consistent indentation level—so an indentation of one tab (or whatever you consider to be a tab stop, like 2 spaces or 4 spaces) should be treated as your code’s “left margin,” with all code in the file relative to that column.

Change Log


  • Initial beta release of CoffeeScript 2. No further breaking changes are anticipated.
  • Destructured objects and arrays now output using ES2015+ syntax whenever possible.
  • Literate CoffeeScript now has much better support for parsing Markdown, thanks to using Markdown-It to detect Markdown sections rather than just looking at indentation.
  • Calling a function named get or set now requires parentheses, to disambiguate from the get or set keywords (which are disallowed).
  • The compiler now requires Node 7.6+, the first version of Node to support asynchronous functions without requiring a flag.


  • Better handling of default, from, as and * within import and export statements. You can now import or export a member named default and the compiler won’t interpret it as the default keyword.
  • Fixed a bug where invalid octal escape sequences weren’t throwing errors in the compiler.


  • Initial alpha release of CoffeeScript 2. The CoffeeScript compiler now outputs ES2015+ syntax whenever possible. See breaking changes.
  • Classes are output using ES2015 class and extends keywords.
  • Added support for async/await.
  • Bound (arrow) functions now output as => functions.
  • Function parameters with default values now use ES2015 default values syntax.
  • Splat function parameters now use ES2015 spread syntax.
  • Computed properties now use ES2015 syntax.
  • Interpolated strings (template literals) now use ES2015 backtick syntax.
  • Improved support for recognizing Markdown in Literate CoffeeScript files.
  • Mixing tabs and spaces in indentation is now disallowed.
  • Browser compiler is now minified using the Google Closure Compiler (JavaScript version).
  • Node 7+ required for CoffeeScript 2.


  • The cake commands have been updated, with new watch options for most tasks. Clone the CoffeeScript repo and run cake at the root of the repo to see the options.
  • Fixed a bug where exporting a referenced variable was preventing the variable from being declared.
  • Fixed a bug where the coffee command wasn’t working for a .litcoffee file.
  • Bugfixes related to tokens and location data, for better source maps and improved compatibility with downstream tools.


  • @ values can now be used as indices in for expressions. This loosens the compilation of for expressions to allow the index variable to be an @ value, e.g. do @visit for @node, @index in nodes. Within @visit, the index of the current node (@node) would be available as @index.
  • CoffeeScript’s patched Error.prepareStackTrace has been restored, with some revisions that should prevent the erroneous exceptions that were making life difficult for some downstream projects. This fixes the incorrect line numbers in stack traces since 1.12.2.
  • The //= operator’s output now wraps parentheses around the right operand, like the other assignment operators.


  • The browser compiler can once again be built unminified via MINIFY=false cake build:browser.
  • The error-prone patched version of Error.prepareStackTrace has been removed.
  • Command completion in the REPL (pressing tab to get suggestions) has been fixed for Node 6.9.1+.
  • The browser-based tests now include all the tests as the Node-based version.


  • You can now import a module member named default, e.g. import { default } from 'lib'. Though like in ES2015, you cannot import an entire module and name it default (so import default from 'lib' is not allowed).
  • Fix regression where from as a variable name was breaking for loop declarations. For the record, from is not a reserved word in CoffeeScript; you may use it for variable names. from behaves like a keyword within the context of import and export statements, and in the declaration of a for loop; though you should also be able to use variables named from in those contexts, and the compiler should be able to tell the difference.


  • CoffeeScript now supports ES2015 tagged template literals. Note that using tagged template literals in your code makes you responsible for ensuring that either your runtime supports tagged template literals or that you transpile the output JavaScript further to a version your target runtime(s) support.
  • CoffeeScript now provides a for…from syntax for outputting ES2015 for…of. (Sorry they couldn’t match, but we came up with for…of first for something else.) This allows iterating over generators or any other iterable object. Note that using for…from in your code makes you responsible for ensuring that either your runtime supports for…of or that you transpile the output JavaScript further to a version your target runtime(s) support.
  • Triple backticks (```​) allow the creation of embedded JavaScript blocks where escaping single backticks is not required, which should improve interoperability with ES2015 template literals and with Markdown.
  • Within single-backtick embedded JavaScript, backticks can now be escaped via \`​.
  • The browser tests now run in the browser again, and are accessible here if you would like to test your browser.
  • CoffeeScript-only keywords in ES2015 imports and exports are now ignored.
  • The compiler now throws an error on trying to export an anonymous class.
  • Bugfixes related to tokens and location data, for better source maps and improved compatibility with downstream tools.


  • Bugfix for shorthand object syntax after interpolated keys.
  • Bugfix for indentation-stripping in """ strings.
  • Bugfix for not being able to use the name “arguments” for a prototype property of class.
  • Correctly compile large hexadecimal numbers literals to 2e308 (just like all other large number literals do).


  • CoffeeScript now supports ES2015 import and export syntax.

  • Added the -M, --inline-map flag to the compiler, allowing you embed the source map directly into the output JavaScript, rather than as a separate file.

  • A bunch of fixes for yield:

    • yield return can no longer mistakenly be used as an expression.

    • yield now mirrors return in that it can be used stand-alone as well as with expressions. Where you previously wrote yield undefined, you may now write simply yield. However, this means also inheriting the same syntax limitations that return has, so these examples no longer compile:

      doubles = ->
        yield for i in [1..3]
          i * 2
      six = ->
          2 * 3
    • The JavaScript output is a bit nicer, with unnecessary parentheses and spaces, double indentation and double semicolons around yield no longer present.

  • &&=, ||=, and= and or= no longer accidentally allow a space before the equals sign.

  • Improved several error messages.

  • Just like undefined compiles to void 0, NaN now compiles into 0/0 and Infinity into 2e308.

  • Bugfix for renamed destructured parameters with defaults. ({a: b = 1}) -> no longer crashes the compiler.

  • Improved the internal representation of a CoffeeScript program. This is only noticeable to tools that use CoffeeScript.tokens or CoffeeScript.nodes. Such tools need to update to take account for changed or added tokens and nodes.

  • Several minor bug fixes, including:

    • The caught error in catch blocks is no longer declared unnecessarily, and no longer mistakenly named undefined for catch-less try blocks.
    • Unassignable parameter destructuring no longer crashes the compiler.
    • Source maps are now used correctly for errors thrown from files.
    • coffee -e 'throw null' no longer crashes.
    • The REPL no longer crashes when using .exit to exit it.
    • Invalid JavaScript is no longer output when lots of for loops are used in the same scope.
    • A unicode issue when using stdin with the CLI.


  • CoffeeScript now supports ES2015-style destructuring defaults.

  • (offsetHeight: height) -> no longer compiles. That syntax was accidental and partly broken. Use ({offsetHeight: height}) -> instead. Object destructuring always requires braces.

  • Several minor bug fixes, including:

    • A bug where the REPL would sometimes report valid code as invalid, based on what you had typed earlier.
    • A problem with multiple JS contexts in the jest test framework.
    • An error in io.js where strict mode is set on internal modules.
    • A variable name clash for the caught error in catch blocks.


  • Bugfix for interpolation in the first key of an object literal in an implicit call.
  • Fixed broken error messages in the REPL, as well as a few minor bugs with the REPL.
  • Fixed source mappings for tokens at the beginning of lines when compiling with the --bare option. This has the nice side effect of generating smaller source maps.
  • Slight formatting improvement of compiled block comments.
  • Better error messages for on, off, yes and no.


  • Fixed a watch mode error introduced in 1.9.1 when compiling multiple files with the same filename.
  • Bugfix for yield around expressions containing this.
  • Added a Ruby-style -r option to the REPL, which allows requiring a module before execution with --eval or --interactive.
  • In <script type="text/coffeescript"> tags, to avoid possible duplicate browser requests for .coffee files, you can now use the data-src attribute instead of src.
  • Minor bug fixes for IE8, strict ES5 regular expressions and Browserify.


  • Interpolation now works in object literal keys (again). You can use this to dynamically name properties.
  • Internal compiler variable names no longer start with underscores. This makes the generated JavaScript a bit prettier, and also fixes an issue with the completely broken and ungodly way that AngularJS “parses” function arguments.
  • Fixed a few yield-related edge cases with yield return and yield throw.
  • Minor bug fixes and various improvements to compiler error messages.


  • CoffeeScript now supports ES2015 generators. A generator is simply a function that yields.
  • More robust parsing and improved error messages for strings and regexes — especially with respect to interpolation.
  • Changed strategy for the generation of internal compiler variable names. Note that this means that @example function parameters are no longer available as naked example variables within the function body.
  • Fixed REPL compatibility with latest versions of Node and Io.js.
  • Various minor bug fixes.


  • The --join option of the CLI is now deprecated.
  • Source maps now use as file extension, instead of just .map.
  • The CLI now exits with the exit code 1 when it fails to write a file to disk.
  • The compiler no longer crashes on unterminated, single-quoted strings.
  • Fixed location data for string interpolations, which made source maps out of sync.
  • The error marker in error messages is now correctly positioned if the code is indented with tabs.
  • Fixed a slight formatting error in CoffeeScript’s source map-patched stack traces.
  • The %% operator now coerces its right operand only once.
  • It is now possible to require CoffeeScript files from Cakefiles without having to register the compiler first.
  • The CoffeeScript REPL is now exported and can be required using require 'coffeescript/repl'.
  • Fixes for the REPL in Node 0.11.


  • Fixed a typo that broke node module lookup when running a script directly with the coffee binary.


  • When requiring CoffeeScript files in Node you must now explicitly register the compiler. This can be done with require 'coffeescript/register' or CoffeeScript.register(). Also for configuration such as Mocha’s, use coffeescript/register.
  • Improved error messages, source maps and stack traces. Source maps now use the updated //# syntax.
  • Leading . now closes all open calls, allowing for simpler chaining syntax.
  • Added **, // and %% operators and ... expansion in parameter lists and destructuring expressions.
  • Multiline strings are now joined by a single space and ignore all indentation. A backslash at the end of a line can denote the amount of whitespace between lines, in both strings and heredocs. Backslashes correctly escape whitespace in block regexes.
  • Closing brackets can now be indented and therefore no longer cause unexpected error.
  • Several breaking compilation fixes. Non-callable literals (strings, numbers etc.) don’t compile in a call now and multiple postfix conditionals compile properly. Postfix conditionals and loops always bind object literals. Conditional assignment compiles properly in subexpressions. super is disallowed outside of methods and works correctly inside for loops.
  • Formatting of compiled block comments has been improved.
  • No more -p folders on Windows.
  • The options object passed to CoffeeScript is no longer mutated.


  • The CoffeeScript REPL now remembers your history between sessions. Just like a proper REPL should.
  • You can now use require in Node to load Literate CoffeeScript files. In the browser, text/literate-coffeescript script tags.
  • The old coffee --lint command has been removed. It was useful while originally working on the compiler, but has been surpassed by JSHint. You may now use -l to pass literate files in over stdio.
  • Bugfixes for Windows path separators, catch without naming the error, and executable-class-bodies-with- prototypal-property-attachment.


  • Source maps have been used to provide automatic line-mapping when running CoffeeScript directly via the coffee command, and for automatic line-mapping when running CoffeeScript directly in the browser. Also, to provide better error messages for semantic errors thrown by the compiler — with colors, even.
  • Improved support for mixed literate/vanilla-style CoffeeScript projects, and generating source maps for both at the same time.
  • Fixes for 1.6.x regressions with overriding inherited bound functions, and for Windows file path management.
  • The coffee command can now correctly fork() both .coffee and .js files. (Requires Node.js 0.9+)


  • First release of source maps. Pass the --map flag to the compiler, and off you go. Direct all your thanks over to Jason Walton.
  • Fixed a 1.5.0 regression with multiple implicit calls against an indented implicit object. Combinations of implicit function calls and implicit objects should generally be parsed better now — but it still isn’t good style to nest them too heavily.
  • is now also supported as a Literate CoffeeScript file extension, for existing tooling. .litcoffee remains the canonical one.
  • Several minor fixes surrounding member properties, bound methods and super in class declarations.


  • First release of Literate CoffeeScript.
  • The CoffeeScript REPL is now based on the Node.js REPL, and should work better and more familiarly.
  • Returning explicit values from constructors is now forbidden. If you want to return an arbitrary value, use a function, not a constructor.
  • You can now loop over an array backwards, without having to manually deal with the indexes: for item in list by -1
  • Source locations are now preserved in the CoffeeScript AST, although source maps are not yet being emitted.


  • The CoffeeScript compiler now strips Microsoft’s UTF-8 BOM if it exists, allowing you to compile BOM-borked source files.
  • Fix Node/compiler deprecation warnings by removing registerExtension, and moving from path.exists to fs.exists.
  • Small tweaks to splat compilation, backticks, slicing, and the error for duplicate keys in object literals.


  • Due to the new semantics of JavaScript’s strict mode, CoffeeScript no longer guarantees that constructor functions have names in all runtimes. See #2052 for discussion.
  • Inside of a nested function inside of an instance method, it’s now possible to call super more reliably (walks recursively up).
  • Named loop variables no longer have different scoping heuristics than other local variables. (Reverts #643)
  • Fix for splats nested within the LHS of destructuring assignment.
  • Corrections to our compile time strict mode forbidding of octal literals.


  • CoffeeScript now enforces all of JavaScript’s Strict Mode early syntax errors at compile time. This includes old-style octal literals, duplicate property names in object literals, duplicate parameters in a function definition, deleting naked variables, setting the value of eval or arguments, and more. See a full discussion at #1547.
  • The REPL now has a handy new multi-line mode for entering large blocks of code. It’s useful when copy-and-pasting examples into the REPL. Enter multi-line mode with Ctrl-V. You may also now pipe input directly into the REPL.
  • CoffeeScript now prints a Generated by CoffeeScript VERSION header at the top of each compiled file.
  • Conditional assignment of previously undefined variables a or= b is now considered a syntax error.
  • A tweak to the semantics of do, which can now be used to more easily simulate a namespace: do (x = 1, y = 2) -> …
  • Loop indices are now mutable within a loop iteration, and immutable between them.
  • Both endpoints of a slice are now allowed to be omitted for consistency, effectively creating a shallow copy of the list.
  • Additional tweaks and improvements to coffee --watch under Node’s “new” file watching API. Watch will now beep by default if you introduce a syntax error into a watched script. We also now ignore hidden directories by default when watching recursively.


  • Multiple improvements to coffee --watch and --join. You may now use both together, as well as add and remove files and directories within a --watch’d folder.
  • The throw statement can now be used as part of an expression.
  • Block comments at the top of the file will now appear outside of the safety closure wrapper.
  • Fixed a number of minor 1.1.3 regressions having to do with trailing operators and unfinished lines, and a more major 1.1.3 regression that caused bound functions within bound class functions to have the incorrect this.


  • Ahh, whitespace. CoffeeScript’s compiled JS now tries to space things out and keep it readable, as you can see in the examples on this page.
  • You can now call super in class level methods in class bodies, and bound class methods now preserve their correct context.
  • JavaScript has always supported octal numbers 010 is 8, and hexadecimal numbers 0xf is 15, but CoffeeScript now also supports binary numbers: 0b10 is 2.
  • The CoffeeScript module has been nested under a subdirectory to make it easier to require individual components separately, without having to use npm. For example, after adding the CoffeeScript folder to your path: require('coffeescript/lexer')
  • There’s a new “link” feature in Try CoffeeScript on this webpage. Use it to get a shareable permalink for your example script.
  • The coffee --watch feature now only works on Node.js 0.6.0 and higher, but now also works properly on Windows.
  • Lots of small bug fixes from @michaelficarra, @geraldalewis, @satyr, and @trevorburnham.


Fixes for block comment formatting, ?= compilation, implicit calls against control structures, implicit invocation of a try/catch block, variadic arguments leaking from local scope, line numbers in syntax errors following heregexes, property access on parenthesized number literals, bound class methods and super with reserved names, a REPL overhaul, consecutive compiled semicolons, block comments in implicitly called objects, and a Chrome bug.


Bugfix release for classes with external constructor functions, see issue #1182.


When running via the coffee executable, process.argv and friends now report coffee instead of node. Better compatibility with Node.js 0.4.x module lookup changes. The output in the REPL is now colorized, like Node’s is. Giving your concatenated CoffeeScripts a name when using --join is now mandatory. Fix for lexing compound division /= as a regex accidentally. All text/coffeescript tags should now execute in the order they’re included. Fixed an issue with extended subclasses using external constructor functions. Fixed an edge-case infinite loop in addImplicitParentheses. Fixed exponential slowdown with long chains of function calls. Globals no longer leak into the CoffeeScript REPL. Splatted parameters are declared local to the function.


Fixed a lexer bug with Unicode identifiers. Updated REPL for compatibility with Node.js 0.3.7. Fixed requiring relative paths in the REPL. Trailing return and return undefined are now optimized away. Stopped requiring the core Node.js util module for back-compatibility with Node.js 0.2.5. Fixed a case where a conditional return would cause fallthrough in a switch statement. Optimized empty objects in destructuring assignment.


CoffeeScript loops no longer try to preserve block scope when functions are being generated within the loop body. Instead, you can use the do keyword to create a convenient closure wrapper. Added a --nodejs flag for passing through options directly to the node executable. Better behavior around the use of pure statements within expressions. Fixed inclusive slicing through -1, for all browsers, and splicing with arbitrary expressions as endpoints.


The REPL now properly formats stacktraces, and stays alive through asynchronous exceptions. Using --watch now prints timestamps as files are compiled. Fixed some accidentally-leaking variables within plucked closure-loops. Constructors now maintain their declaration location within a class body. Dynamic object keys were removed. Nested classes are now supported. Fixes execution context for naked splatted functions. Bugfix for inversion of chained comparisons. Chained class instantiation now works properly with splats.


0.9.5 should be considered the first release candidate for CoffeeScript 1.0. There have been a large number of internal changes since the previous release, many contributed from satyr’s Coco dialect of CoffeeScript. Heregexes (extended regexes) were added. Functions can now have default arguments. Class bodies are now executable code. Improved syntax errors for invalid CoffeeScript. undefined now works like null, and cannot be assigned a new value. There was a precedence change with respect to single-line comprehensions: result = i for i in list used to parse as result = (i for i in list) by default … it now parses as (result = i) for i in list.


CoffeeScript now uses appropriately-named temporary variables, and recycles their references after use. Added require.extensions support for Node.js 0.3. Loading CoffeeScript in the browser now adds just a single CoffeeScript object to global scope. Fixes for implicit object and block comment edge cases.


CoffeeScript switch statements now compile into JS switch statements — they previously compiled into if/else chains for JavaScript 1.3 compatibility. Soaking a function invocation is now supported. Users of the RubyMine editor should now be able to use --watch mode.


Specifying the start and end of a range literal is now optional, eg. array[3..]. You can now say a not instanceof b. Fixed important bugs with nested significant and non-significant indentation (Issue #637). Added a --require flag that allows you to hook into the coffee command. Added a custom jsl.conf file for our preferred JavaScriptLint setup. Sped up Jison grammar compilation time by flattening rules for operations. Block comments can now be used with JavaScript-minifier-friendly syntax. Added JavaScript’s compound assignment bitwise operators. Bugfixes to implicit object literals with leading number and string keys, as the subject of implicit calls, and as part of compound assignment.


Bugfix release for 0.9.1. Greatly improves the handling of mixed implicit objects, implicit function calls, and implicit indentation. String and regex interpolation is now strictly #{ … } (Ruby style). The compiler now takes a --require flag, which specifies scripts to run before compilation.


The CoffeeScript 0.9 series is considered to be a release candidate for 1.0; let’s give her a shakedown cruise. 0.9.0 introduces a massive backwards-incompatible change: Assignment now uses =, and object literals use :, as in JavaScript. This allows us to have implicit object literals, and YAML-style object definitions. Half assignments are removed, in favor of +=, or=, and friends. Interpolation now uses a hash mark # instead of the dollar sign $ — because dollar signs may be part of a valid JS identifier. Downwards range comprehensions are now safe again, and are optimized to straight for loops when created with integer endpoints. A fast, unguarded form of object comprehension was added: for all key, value of object. Mentioning the super keyword with no arguments now forwards all arguments passed to the function, as in Ruby. If you extend class B from parent class A, if A has an extended method defined, it will be called, passing in B — this enables static inheritance, among other things. Cleaner output for functions bound with the fat arrow. @variables can now be used in parameter lists, with the parameter being automatically set as a property on the object — useful in constructors and setter functions. Constructor functions can now take splats.


Quick bugfix (right after 0.7.1) for a problem that prevented coffee command-line options from being parsed in some circumstances.


Block-style comments are now passed through and printed as JavaScript block comments – making them useful for licenses and copyright headers. Better support for running coffee scripts standalone via hashbangs. Improved syntax errors for tokens that are not in the grammar.


Official CoffeeScript variable style is now camelCase, as in JavaScript. Reserved words are now allowed as object keys, and will be quoted for you. Range comprehensions now generate cleaner code, but you have to specify by -1 if you’d like to iterate downward. Reporting of syntax errors is greatly improved from the previous release. Running coffee with no arguments now launches the REPL, with Readline support. The <- bind operator has been removed from CoffeeScript. The loop keyword was added, which is equivalent to a while true loop. Comprehensions that contain closures will now close over their variables, like the semantics of a forEach. You can now use bound function in class definitions (bound to the instance). For consistency, a in b is now an array presence check, and a of b is an object-key check. Comments are no longer passed through to the generated JavaScript.


The coffee command will now preserve directory structure when compiling a directory full of scripts. Fixed two omissions that were preventing the CoffeeScript compiler from running live within Internet Explorer. There’s now a syntax for block comments, similar in spirit to CoffeeScript’s heredocs. ECMA Harmony DRY-style pattern matching is now supported, where the name of the property is the same as the name of the value: {name, length}: func. Pattern matching is now allowed within comprehension variables. unless is now allowed in block form. until loops were added, as the inverse of while loops. switch statements are now allowed without switch object clauses. Compatible with Node.js v0.1.95.


Upgraded CoffeeScript for compatibility with the new Node.js v0.1.90 series.


Trailing commas are now allowed, a-la Python. Static properties may be assigned directly within class definitions, using @property notation.


Interpolation can now be used within regular expressions and heredocs, as well as strings. Added the <- bind operator. Allowing assignment to half-expressions instead of special ||=-style operators. The arguments object is no longer automatically converted into an array. After requiring coffeescript, Node.js can now directly load .coffee files, thanks to registerExtension. Multiple splats can now be used in function calls, arrays, and pattern matching.


String interpolation, contributed by Stan Angeloff. Since --run has been the default since 0.5.3, updating --stdio and --eval to run by default, pass --compile as well if you’d like to print the result.


Bugfix that corrects the Node.js global constants __filename and __dirname. Tweaks for more flexible parsing of nested function literals and improperly-indented comments. Updates for the latest Node.js API.


CoffeeScript now has a syntax for defining classes. Many of the core components (Nodes, Lexer, Rewriter, Scope, Optparse) are using them. Cakefiles can use to define options for tasks. --run is now the default flag for the coffee command, use --compile to save JavaScripts. Bugfix for an ambiguity between RegExp literals and chained divisions.


Added a compressed version of the compiler for inclusion in web pages as /v2/browser-compiler/coffeescript.js. It’ll automatically run any script tags with type text/coffeescript for you. Added a --stdio option to the coffee command, for piped-in compiles.


Improvements to null soaking with the existential operator, including soaks on indexed properties. Added conditions to while loops, so you can use them as filters with when, in the same manner as comprehensions.


CoffeeScript 0.5.0 is a major release, While there are no language changes, the Ruby compiler has been removed in favor of a self-hosting compiler written in pure CoffeeScript.


@property is now a shorthand for Switched the default JavaScript engine from Narwhal to Node.js. Pass the --narwhal flag if you’d like to continue using it.


CoffeeScript 0.3 includes major syntax changes: The function symbol was changed to ->, and the bound function symbol is now =>. Parameter lists in function definitions must now be wrapped in parentheses. Added property soaking, with the ?. operator. Made parentheses optional, when invoking functions with arguments. Removed the obsolete block literal syntax.


Added Python-style chained comparisons, the conditional existence operator ?=, and some examples from Beautiful Code. Bugfixes relating to statement-to-expression conversion, arguments-to-array conversion, and the TextMate syntax highlighter.


The conditions in switch statements can now take multiple values at once — If any of them are true, the case will run. Added the long arrow ==>, which defines and immediately binds a function to this. While loops can now be used as expressions, in the same way that comprehensions can. Splats can be used within pattern matches to soak up the rest of an array.


Added ECMAScript Harmony style destructuring assignment, for dealing with extracting values from nested arrays and objects. Added indentation-sensitive heredocs for nicely formatted strings or chunks of code.


Axed the unsatisfactory ino keyword, replacing it with of for object comprehensions. They now look like: for prop, value of object.


When performing a comprehension over an object, use ino, instead of in, which helps us generate smaller, more efficient code at compile time. Added :: as a shorthand for saying .prototype. The “splat” symbol has been changed from a prefix asterisk *, to a postfix ellipsis ... Added JavaScript’s in operator, empty return statements, and empty while loops. Constructor functions that start with capital letters now include a safety check to make sure that the new instance of the object is returned. The extends keyword now functions identically to goog.inherits in Google’s Closure Library.


Arguments objects are now converted into real arrays when referenced.


Major release. Significant whitespace. Better statement-to-expression conversion. Splats. Splice literals. Object comprehensions. Blocks. The existential operator. Many thanks to all the folks who posted issues, with special thanks to Liam O’Connor-Davis for whitespace and expression help.


Bugfix for running coffee --interactive and --run from outside of the CoffeeScript directory. Bugfix for nested function/if-statements.


Array slice literals and array comprehensions can now both take Ruby-style ranges to specify the start and end. JavaScript variable declaration is now pushed up to the top of the scope, making all assignment statements into expressions. You can use \ to escape newlines. The coffeescript command is now called coffee.


The official CoffeeScript extension is now .coffee instead of .cs, which properly belongs to C#. Due to popular demand, you can now also use = to assign. Unlike JavaScript, = can also be used within object literals, interchangeably with :. Made a grammatical fix for chained function calls like func(1)(2)(3)(4). Inheritance and super no longer use __proto__, so they should be IE-compatible now.


The coffee command now includes --interactive, which launches an interactive CoffeeScript session, and --run, which directly compiles and executes a script. Both options depend on a working installation of Narwhal. The aint keyword has been replaced by isnt, which goes together a little smoother with is. Quoted strings are now allowed as identifiers within object literals: eg. {"5+5": 10}. All assignment operators now use a colon: +:, -:, *:, etc.


Fixed a bug with calling super() through more than one level of inheritance, with the re-addition of the extends keyword. Added experimental Narwhal support (as a Tusk package), contributed by Tom Robinson, including bin/cs as a CoffeeScript REPL and interpreter. New --no-wrap option to suppress the safety function wrapper.


Added instanceof and typeof as operators.


Initial CoffeeScript release.