-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
40 lines (33 loc) · 893 Bytes
/
index.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
(function(context) {
function demo() {
console.log('\n\nOBJECT LITERALS');
const employee = {
id: '1234',
name: {
title: 'Dr.',
firstName: 'Strange',
lastName: ''
},
address: {
street: '890',
locality: 'Fifth Avenue',
city: 'Manhattan',
state: 'New York',
}
};
// Use of object destructuring
const { title, firstName, lastName } = employee.name;
const name = `${title} ${firstName} ${lastName}`;
const { street, locality, city, state } = employee.address;
const address = `${street} ${locality} ${city} ${state}`;
// Use of object literals
const employeeShort = {
name,
address,
id: employee.id,
};
console.log(employee);
console.log(employeeShort);
}
(context || this).demoLibs['object-literals'] = demo;
})(window);