String Interpolation

CoffeeScript brings Ruby style string interpolation to JavaScript. Double quotes strings can contain #{} tags, which contain expressions to be interpolated into the string:

favorite_color = "Blue. No, yel..."
question = "Bridgekeeper: What... is your favorite color?
            Galahad: #{favorite_color}
            Bridgekeeper: Wrong!
            "

As you can see in this example, multiline strings are also allowed, without having to prefix each line with a +.

Get The Little Book on 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.