Last active
September 15, 2019 18:38
-
-
Save paigen11/963ce5d596391ef7ce82459caef8a012 to your computer and use it in GitHub Desktop.
Template literal examples: single line, multi-line, and expression placeholders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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