Posted On: Feb 22, 2018
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 ECMAScript.
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 backtick “ 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;
Never Miss an Articles from us.
Es6 or ECMASCRIPT 2015 is sixth major release of ECMAScript language which comes with a lot of new features and syntax..
New Features in ES6. Support for constants (also known as “immutable variables”) Block-Scope support for both varia..
Babel is one of the most popular JavaScript transpilers and becomes the industry standard. It allows us to write ES6 cod..