© Raju Gandhi 2019
R. GandhiJavaScript Nexthttps://doi.org/10.1007/978-1-4842-5394-6_5

5. Formatted Strings Using Template Strings

Raju Gandhi1 
(1)
Columbus, OH, USA
 

Introduction

Ever tried to create a dynamic string in JavaScript that involved interpolating more than one variable at a time? I always seem to mess up the + and the quotes somehow. And heaven forbid we must format it in a particular way with new-lines and indentation. Also, let’s not talk about ever changing that once we get it written out, shall we?

In this chapter we will forever forgo string concatenation in lieu of template strings which allow us to lay out strings that interpolate variables and expressions in a clear and declarative manner. We will also explore tag functions, which ...

Get JavaScript Next: Your Complete Guide to the New Features Introduced in JavaScript, Starting from ES6 to ES9 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.