O'Reilly logo

CoffeeScript Application Development Cookbook by Mike Hatfield

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

Working with strings

In this section, we will look at the various aspects of working with strings or text-based data.

String interpolation

In this section, we will demonstrate the CoffeeScript feature of string interpolation.

Getting ready

In JavaScript, creating strings that include variable values involves concatenating the various pieces together. Consider the following example:

var lineCount = countLinesInFile('application.log');
var message = "The file has a total of " + lineCount + " lines";
console.log(message);

This can get pretty messy and CoffeeScript provides an elegant solution to avoid this called string interpolation.

How to do it...

CoffeeScript provides the ability to perform string interpolation by using double quoted strings containing ...

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