-
Notifications
You must be signed in to change notification settings - Fork 0
/
templete.js
26 lines (21 loc) · 1019 Bytes
/
templete.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Templet literal is another important feature of ES6. It is frequennly used in react node js. templete literal is nothing
// but to write something by using backtic `abcd`.
var a = 5;
var b = 6;
// Now i want to write I am 5 and i am 6
// console.log("I am" + a + " and I am " + b);
// output: I am5 and I am 6 **This is old method.This also called string interpolation.
// Now by using templet literel i can write this together easily.all variables should be written as `${variable}`. This
// is called variable interpolation.
// console.log(`I am ${a} and I am ${b}`);
// console.log(a+b);
// console.log(a*b);
// output: am 5 and I am 6 11 30
// console.log("I am sumon
// i love programming");
// it will give error because we can't write in second line. But by using templete literel i can do this second line writing.
// now if i conver it into templete literel then i can write in multiline.
console.log(`I am sumon
i love programming`);
// output:I am sumon
// i love programming