Skip to content

Commit aff5b93

Browse files
committed
update nested obj
1 parent 00a0f6c commit aff5b93

File tree

1 file changed

+28
-34
lines changed

1 file changed

+28
-34
lines changed

Objects/02_nested_obj.js

+28-34
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,34 @@
1-
const newnames = 'apple.inc';
2-
const age = 20;
3-
let random = 'random-value';
1+
// nested object
42

5-
const person = {
6-
name: 'john doe',
7-
age: age,
8-
company: {
9-
name: newnames,
10-
job: 'front end developer',
3+
const newHobby = ['run', 'basket', 'football'];
4+
const notRandom = 'Dumpak dug dug deeerrr';
5+
const john = {
6+
firstName: 'john',
7+
status: {
8+
married: false,
9+
student: true,
1110
},
12-
married: true,
13-
expert: {
14-
skills: ['html', 'css3', 'js'],
15-
hobby: {
16-
books: ['onepiece', 'shokugeki no souma'],
11+
skills: {
12+
technology: {
13+
webdesign: ['html', 'css', 'figma', 'javascript'],
14+
backend: ['nodejs', 'django'],
1715
},
1816
},
19-
'random-value': 'jobss!',
17+
hobby: {
18+
manga: {
19+
read: ['onepiece', 'sololeveling'],
20+
sport: newHobby,
21+
},
22+
},
23+
randomhere: notRandom,
2024
};
2125

22-
// acces all obj
23-
// console.log(person);
24-
25-
// *** acces on nested
26-
// front end developer
27-
console.log(person.company.job);
28-
// [ 'html', 'css3', 'js' ]
29-
console.log(person.expert.skills);
30-
// shokugeki no souma
31-
console.log(person.expert.hobby.books[1]);
32-
console.log('random-value');
33-
// apple.inc
34-
console.log(person.company.name);
35-
console.log(person['random-value']);
36-
// { name: 'apple.inc', job: 'front end developer' }
37-
// still same with person.company
38-
console.log(person['company']);
39-
40-
console.log(person.age);
26+
// access
27+
console.log(john.status.married); //false
28+
console.log(john.status.skills); //undefined
29+
console.log(
30+
john.skills.technology.webdesign[john.skills.technology.webdesign.length - 1]
31+
); //javascript
32+
console.log(john.hobby.manga.read); //['onepiece', 'sololeveling'];
33+
console.log(john.hobby.manga.sport); //[ 'run', 'basket', 'football' ]
34+
console.log(john.randomhere); //random

0 commit comments

Comments
 (0)