File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -64,9 +64,30 @@ const person = {
6464console . 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
71921 ) Using object literal
72932 ) By creating instance of Object directly
You can’t perform that action at this time.
0 commit comments