Sait-C / TemplateLiterals

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TemplateLiterals

Template Literals (formerly Template Strings) is a form of string writing that came with ES6 that provides code readability and ease of writing.

Benefits

Multi-Line String Writing:

//Old Usage:
let oldString = "My favorite foods:\nPasta\nHamburger"

//New Usage:
let newString = `My favorite foods:
                  Pasta
                  Hamburger
                  Meatball`

Interpolation

  • Interpolation means using variables in text. It is used to embed expressions within regular strings.
let a = 99;
let b = 999;

console.log(`${a} times ${b} equals ${a*b}`);

//Output: 
//99 times 999 equals 98901

Readability

DesignForReadability

It makes template tags less complex.

An Example

About


Languages

Language:JavaScript 100.0%