Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

accessing nested objects in javascript

const user = {
    id: 101,
    email: 'jack@dev.com',
    personalInfo: {
        name: 'Jack',
        address: {
            line1: 'westwish st',
            line2: 'washmasher',
            city: 'wallas',
            state: 'WX'
        }
    }
}

const name = user.personalInfo.name;
const userCity = user.personalInfo.address.city;
Source by hackernoon.com #
 
PREVIOUS NEXT
Tagged: #accessing #nested #objects #javascript
ADD COMMENT
Topic
Name
5+1 =