-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathobjects.js
More file actions
56 lines (45 loc) · 1.16 KB
/
Copy pathobjects.js
File metadata and controls
56 lines (45 loc) · 1.16 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
let obj =
{
key: 'value'
};
console.log(obj);
// Access value by key
console.log(obj.key);
// Access value by property name
console.log(obj['key']);
console.log();
let data =
{
name: 'Billy',
age: 16,
profession: 'Developer',
married: false
};
// Key
console.log(data);
console.log(data.name);
console.log(data.age);
console.log(data.profession);
console.log(data.married);
// Property
console.log(data['name']);
console.log(data['age']);
console.log(data['profession']);
console.log(data['married']);
// Concat the values
console.log(data.name + ' is a ' + data.age + ' year old ' + data.profession + '. He is ' + (data.married ? 'married' : 'not married') + ' yet.');
console.log();
let items =
{
firstName: 'Sendy',
lastName: 'Friscilla',
information:
{
age: 10,
profession: 'Student',
hobby: ['Playing games', 'Reading books', 'Watching movies']
}
}
console.log(`Name: ${items.firstName} ${items.lastName}`);
console.log(`Information: Age ${items.information.age}, Profession ${items.information.profession}, Hobby ${items.information.hobby}`);
console.log(`Hobby: ${items.information.hobby[0]}`);