| 1. |
What Are Template Literals In Es6? |
|
Answer» <P>Template literals are the string with embedded code and variables inside. Template LITERAL allows concatenation and interpolation in much more comprehensive and clear in comparison with prior versions of Ecma script. Let see an example of concatenating a string in javascript. var a="Hello"; var b="John"; var c = a+ " " + b; Console.log(c); //outputs Hello John; In ES6 concatenation and interpolation is done by back TICK “ in a single line. To interpolate a variable SIMPLY put in to {} braces forwarded by $ sign.>/p> // In ES6 let a="Hello"; let b="John"; let c=`${a} ${b}`; console.log(c); //outputs Hello John; Template literals are the string with embedded code and variables inside. Template literal allows concatenation and interpolation in much more comprehensive and clear in comparison with prior versions of Ecma script. Let see an example of concatenating a string in javascript. var a="Hello"; var b="John"; var c = a+ " " + b; Console.log(c); //outputs Hello John; In ES6 concatenation and interpolation is done by back tick “ in a single line. To interpolate a variable simply put in to {} braces forwarded by $ sign.>/p> // In ES6 let a="Hello"; let b="John"; let c=`${a} ${b}`; console.log(c); //outputs Hello John; |
|