Skip to content

Instantly share code, notes, and snippets.

@paigen11
Last active September 15, 2019 18:38
Show Gist options
  • Save paigen11/963ce5d596391ef7ce82459caef8a012 to your computer and use it in GitHub Desktop.
Save paigen11/963ce5d596391ef7ce82459caef8a012 to your computer and use it in GitHub Desktop.
Template literal examples: single line, multi-line, and expression placeholders
// just a normal string in one line - not much different from a traditional string
const simpleString = `a template literal is surrounded by backticks`;
// a string spread across multiple lines
const multiLineString = `it can be spread across
multiple lines with just
one set of enclosing backticks`;
const name = "Paige";
// an expression placeholder allowing a variable to be injected into the string
const greetByName = `Hello, ${name}`;
console.log(greetByName); // 'Hello, Paige'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment