O'Reilly logo

CoffeeScript in Action by Patrick Lee

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

Chapter 4. Dynamic objects

This chapter covers

  • Objects as data
  • Object comprehensions
  • An introduction to prototypes
  • An introduction to classes

JavaScript objects are simple and powerful, but because they don’t work quite like objects in other popular programming languages, they’re often wrongly perceived as confusing and underpowered. With simplified and familiar syntax, CoffeeScript both eliminates the confusion and better exposes the inherent power of objects. Before diving in, though, what exactly is an object?

Objects are collections of named properties where each name maps to a value. The value of a property can be any valid CoffeeScript value. You write an empty object with a set of curly braces:

{}

That is an object, in literal ...

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