3. Control Structures

Almost all languages have the concept of operators1 and conditionals;2 JavaScript and CoffeeScript are no different. Operators and conditionals work hand in hand to form an important part of all programming languages. Operators let you do things such as add or subtract two numbers, compare two objects, shift bytes in an object, and so on. Conditionals, on the other hand, let us control the flow of our application based on certain predefined conditions. For example if a user is not logged in then send them to the login screen, else show them the secret page. That is a conditional statement.

In this chapter we take a look at both operators and conditionals and how they are defined in CoffeeScript.

Operators and Aliases

For ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.