Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JavaScript Nested Objects

// nested object
const student = { 
    name: 'John', 
    age: 20,
    marks: {
        science: 70,
        math: 75
    }
}

// accessing property of student object
console.log(student.marks); // {science: 70, math: 75}

// accessing property of marks object
console.log(student.marks.science); // 70
Source by hackernoon.com #
 
PREVIOUS NEXT
Tagged: #JavaScript #Nested #Objects
ADD COMMENT
Topic
Name
4+3 =