-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataStructuring.html
More file actions
42 lines (37 loc) · 1.08 KB
/
Copy pathDataStructuring.html
File metadata and controls
42 lines (37 loc) · 1.08 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Data Destructuring</title>
</head>
<body>
<script>
// Object Destructuring
// Destructuring Assignment
// Nested Obhect Destructuring
let obj = {
name: "Jordan",
age: 10,
address: {city: 'Ibadan', state: 'Oyo'}
}
// const {age, name} = obj
// console.log(name);
const arry = [1,2,3,4,5,6]
const [a,b, ...rest] = arry
// instead of console.log(arry[0]);
console.log(a);
// instead of console.log([arry[2],arry[3],arry[4],arry[5]]);
console.log(rest);
// Nested Obhect Destructuring
const{name, age, address:{city, state}} = obj
// instead of obj.address.city
console.log(city);
let even = [2,4,6]
let odd = [1,3,5]
// instead of let num = even.concat(odd)
let num = [...even, ...odd]
console.log(num);
</script>
</body>
</html>