Chapter 3. First-class functions

This chapter covers

  • Functions for representing computation
  • Functions for events and event-driven I/O
  • An introduction to higher-order functions
  • Variable scope and closures

If you asked a dozen JavaScript programmers what they thought JavaScript got wrong, you’d probably get a dozen different answers. If you asked those same dozen people what JavaScript got right, they’d probably all answer, “First-class functions.” What does it mean that JavaScript has first-class functions, why does it matter, and how does CoffeeScript make functions even better? All will be answered in good time. First, though, what exactly is a function?

A function defines a transformation of input values called parameters to an output ...

Get CoffeeScript in Action now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.