- Part 1: Let and Const
- Part 2: Template Literals
- Part 3: Default Parameter Values
- Part 4: Arrow Functions
- Part 5: Classes
The concept of template literals helps with this very issue. Instead of concatenating different values, the use of template literals allows for writing code where values will be placed into the string during run-time.
Creating Template Literals
Template literals depend on two different syntax usages. The first is that a string which contains template literals must be set off using backticks around it. This differs from the normal single or double-quotes that would be around a string. The second is that variables must be contained within curly brackets and have a dollar sign in front of them.
Using Template Literals
The result of the use of a template literal is a string. This means that template literals can be used to display content made up of the values of variables. When used in a web development context, for example, this can be very helpful to dynamically create content.