-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathES6 destruct.js
68 lines (55 loc) · 1.31 KB
/
ES6 destruct.js
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//const companies = [
// {name: 'Google', loc: 'Mountain View'},
// {name: 'Facebook', loc: 'Menlo Park'},
// {name: 'Uber', loc: 'San Francisco'}
//];
//
//const [{ loc }] = companies;
//console.log(loc);
//########### 2
//const Google = {
// locations: ['Mountain View', 'New York', 'London'],
// headquarter: 'USA'
//}
//
//const {locations} = Google;
//console.log(locations);
//console.log(loc);
//// ##### 3
//function signup({password, username, dataOfBirth, email, city}) {
// //create user
// console.log(password);
// console.log(username);
//}
//
//const user = {
// username: 'myName',
// password: 'mypassword',
// email: '[email protected]',
// dateOfBirth: '1/1/1900',
// city: 'New York'
//};
//signup(user);
const points = [
[4, 5],
[10, 1],
[0, 40]
];
const formatedPoints = points.map(([x, y]) => {
return {x, y};
});
console.log(formatedPoints);
const classes = [
[ 'Chemistry', '9AM', 'Mr. Darnick' ],
[ 'Physics', '10:15AM', 'Mrs. Lithun'],
[ 'Math', '11:30AM', 'Mrs. Vitalis' ]
];
const classesAsObject = classes.map(([subject, time, teacher]) => {
return {subject, time, teacher};
});
console.log(classesAsObject);
const Google = {
locs: ['Mountain View', 'New York', 'London']
};
const {locs} = Google;
console.log(`sss: ${locs}`);