Skip to content

Latest commit

 

History

History
30 lines (19 loc) · 616 Bytes

Templates & Strings.md

File metadata and controls

30 lines (19 loc) · 616 Bytes

Templates & Strings

Variable bindings are possible in ES6 using ${}.

Demo

let name = 'Foo';

var myMsg = `Hello ${name}`;

alert(myMsg); //alert Hello Foo

Note: I have not used single quotes here.

Multiline strings

In vanilla JS, to create multiline we have to use \n. But in ES6, writing in next line will be taken as new line.

Demo

let myMsg = `In ES6 multi line 
 is so easy to create.`

alert(myMsg); 
//alert In ES6 multi line 
// is so easy to create.