bradxr
8/4/2018 - 12:46 PM

Create Strings Using Template Literals

Template literals are a new feature of ES6 Special type of string that makes creating complex strings easier Allow you to create multi-line strings and use string interpolation features to create strings

const person = {
  name: "Zodiac Hasbro",
  age: 56
};

// template literal with multi-line and string interpolation
const greeting = `Hello, my name is ${person.name}! I am ${person.age} years old.`;

console.log(greeting);  // Hello, my name is Zodiac Hasbro! I am 56 years old.

// NOTE: string uses backticks (`), not quotes