Skip to content

Commit 0799b45

Browse files
authored
Update Objects.js
1 parent f96a5bf commit 0799b45

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/Objects.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,30 @@ const person = {
6464
console.log(person["name"]); // John
6565

6666

67+
// JavaScript Nested Objects
68+
An object can also contain another object. For example,
69+
70+
// nested object
71+
const student = {
72+
name: 'John',
73+
age: 20,
74+
marks: {
75+
science: 70,
76+
math: 75
77+
}
78+
}
79+
80+
// accessing property of student object
81+
console.log(student.marks); // {science: 70, math: 75}
82+
83+
// accessing property of marks object
84+
console.log(student.marks.science); // 70
85+
In the above example, an object student contains an object value in the marks property.
86+
87+
6788

6889

69-
// Creating Objects using 3 diff ways
90+
// Creating Objects using 3 diff ways
7091

7192
1) Using object literal
7293
2) By creating instance of Object directly

0 commit comments

Comments
 (0)