-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdestructure.html
More file actions
40 lines (30 loc) · 761 Bytes
/
Copy pathdestructure.html
File metadata and controls
40 lines (30 loc) · 761 Bytes
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title> Destructuring Assignment </title>
<script>
// uncomment each section one at a time to try it.
let colas = ["Cola", "Diet Cola", "Root Beer"];
let [cola, diet, rootBeer] = colas;
//console.log(`${cola}, ${diet}, ${rootBeer}`);
//let [cola, diet, rootBeer, orange = "Orange"] = colas;
//console.log(orange);
//let [cola, ...drinks] = colas;
//console.log(cola);
//console.log(drinks);
let fido = {
name: "Fido",
breed: "Mixed",
weight: 35
};
let {name, breed, weight = 30, handler = "Cookie"} = fido;
console.log(`${name}, ${breed}, ${weight}, ${handler}`);
//let {name, ...restOfDog} = fido;
//console.log(name);
//console.log(restOfDog);
</script>
</head>
<body>
</body>
</html>