Template Literals in ES6 tutorial

Learn how to use ES6 JavaScript template literals.

In this tutorial about ES6 template literals (otherwise known as ES6 template strings) you’ll learn how to use this feature of ES6 to create strings. You will learn three advantages of using ES6 template literals rather than using plain old JavaScript strings. We’ll do this by converting an existing ES5 string to a new ES6 template string. Along the way, you’ll get to know how you can use the template literal feature to remove unnecessary concatenation from your existing strings. Also, you’ll see how escape sequences (like backslashes for apostrophes and new line codes) can be removed as everything inside the ES6 template string can be treated as just that - a literal string. The final thing you’ll learn about is how to interpolate variables into ES6 template strings. You won’t need to concatenate variables into your strings any more, you can use the features available to you in order to seamlessly add variables in to your ES6 template strings.