Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In my travels as a developer, I have yet to meet a programming language that didn’t have the concept of conditional statements. I’m sure somebody out there has written one, but I doubt that it is heavily used outside of that person’s parent’s basement.
Conditionals allow our programs to become intelligent. They let us program applications that can react to different situations. Is there a logged in user? If not, ask her to log in; otherwise, show her the secret account page. Has the current user paid his bill? If he has, give him access to his account; if not, tell him to pay. These are examples of conditional statements. The program takes a different path through its execution based on the answers to these questions.
CoffeeScript, like almost every other programming language, offers conditionals. These conditional statements will typically be used with the operators and aliases we’ve already seen in this chapter to help the program make more intelligent decisions.