-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.16-Spread-Operator.html
43 lines (39 loc) · 1.08 KB
/
1.16-Spread-Operator.html
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
<!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>ECMA-6 Spread Operator</title>
</head>
<body>
<h2>ECMA-6 Spread Operator</h2>
<script>
const numArray1 = [11, 22, 33];
const numArr2 = [99, 01, 44];
const newArray = [...numArray1, ...numArr2];
console.log(newArray);//spread operator joins arrays or adds new items to existing array
const newArr2 = [...numArray1, 66, 23];
console.log(newArr2);
let empArr = [
{
id : 81,
Name : "Kinshuk",
Age : 21
},
{
id : 69,
Name : "Jagjeet",
Age : 22
},
{
id : 132,
Name : "Rishi",
Age : 20
}
];
empArr = [...empArr , {id : 87 ,Name :"Kunaal",Age: 21}];
console.log(empArr);
</script>
</body>
</html>