Created
August 13, 2017 13:12
-
-
Save prof3ssorSt3v3/6f8572b10505de8ebe657792a3c75200 to your computer and use it in GitHub Desktop.
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
// template strings / template literals ES6 | |
// | |
// wrapped with back-tick character like table names in SQL | |
// Variables and expressions wrapped in ${ } | |
// Tagged Template Literals | |
const log = console.log; | |
let message = 'I\'m going to the store'; | |
let message1 = "And then he said, \"That's what she said.\""; | |
let item = 'Heineken'; | |
let message2 = 'I\'m going to buy ' + item + ' at the store'; | |
let message3 = ''.concat('I\'m going to buy ', item, ' at the store'); | |
let arr = ['a','b','c']; | |
let message4 = 'The first letter is ' + arr[0] + '.'; | |
let msg = `I'm going to buy ${item.toUpperCase()} at the store`; | |
log(msg); | |
function bubba(strings, ...expressions){ | |
log(strings.length); | |
log(expressions.length); | |
return strings[1] + strings[0] + expressions[0]; | |
} | |
let str = bubba`x ${item} x`; | |
console.log(str); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment