15

Combining Strings and Variables

In this Chapter

  • Learn how to create complex strings by combining variables

  • Learn about template literals

Ah, yes, it’s time for us to look at the ancient art of combining strings and variables, where we generate a string made up of literal (static) text values along with variables whose values are defined as a result of some JavaScript operation. This is an important topic for us to look at because we will find ourselves combining strings and variables quite often—whether it is for printing messages to the console, specifying a key to some object, generating a complex CSS property value, or trying to accomplish a boatload of other things.

In the following sections, we’ll look at the two best approaches ...

Get Javascript Absolute Beginner's Guide, 3rd Edition 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.