-
Notifications
You must be signed in to change notification settings - Fork 119
/
EcmaScript_part1
51 lines (42 loc) · 1.47 KB
/
EcmaScript_part1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// String templates and string Methods
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Methods of Template strings</title>
</head>
<body>
<h1>
This is tutorial of EcmaScript(ES6).
</h1>
<script>
//ES5
console.log("My name is Pushkar."+"I am 22 years old."+"this is way to concat 3 strings in normal js.")
//ES6
console.log(`My name is Pushkar.I am 22 years old.This is way to concat 3 strings in ES6.`)
let Firstname="Pushkar";
let sname="choudhary";
// ES5
console.log("My first name is "+Firstname+" "+"My last name is"+sname);
//ES6
console.log(`My first name is ${Firstname} My last name is ${sname}`);
let a=20;
let b=30;
// ES5
console.log("Fifty is "+(a+b)+ ' and /n not seventy' + (2*a+b));
//ES6
console.log(`Fifty is ${a+b} and
not seventy ${2*a+b}`);
// Methods of string templates
let fname=`${Firstname}`;
console.log(`${Firstname}`.startsWith('P'));
console.log(`${Firstname}`.endsWith('r'));
console.log(`${Firstname}`.includes('ush'));
console.log(`${Firstname}`.includes('usr'));
console.log(`${Firstname} ${sname} `.repeat(10));
console.log(fname .repeat(10));
</script>
</body>
</html>