Created
February 16, 2016 13:42
-
-
Save KKrisu/896f85d6241285cc0423 to your computer and use it in GitHub Desktop.
ES6 Strings, Templates
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
// var text = `something`; | |
// var template = '' + | |
// '<div>' + | |
// '<input>' + | |
// '</div>'; | |
// console.log(template); | |
// var template2 = ` | |
// <div> | |
// <input> | |
// </div> | |
// `; | |
// console.log(template2); | |
var beers = 3; | |
// var o = { | |
// when: 'today', | |
// }; | |
// var text = `I have ${beers - 2} bears ${Math.PI}`; | |
// console.log(text); | |
// function transform(strings, ...values) { | |
// var result = ''; | |
// for(let i = 0; i < strings.length; i++) { | |
// result += strings[i].replace('bear', 'wine'); | |
// if(values.length) { | |
// result += values.shift(); | |
// } | |
// } | |
// return result; | |
// } | |
// var text = transform`I have ${beers - 2} bears ${Math.PI}`; | |
// console.log(text); | |
// var text = String.raw`foo \n bar \t baz`; | |
// console.log(text); | |
// var text = `I have beer`; | |
// console.log(text.includes('have')); | |
// console.log(text.startsWith('sdf')); | |
// console.log(text.endsWith('beer')); | |
// console.log(text.repeat(3)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment