var backPack = {
color: 'black',
straps: 4,
isHeavy: true,
wallet: {
cash: '$10,000',
creditCards: 6
}
tablet: {
brand: 'Apple iPad',
buttons: 1
}
};
const myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};
const gloveBoxContents = myStorage.car.inside['glove box']; // maps
// 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
Do my eyes decieve me, or is the second answer the same as the first, but
with more upvotes?
const name = ((user || {}).personalInfo || {}).name;
const employeeInfo = {
employeeName: "John Doe",
employeeId: 27,
salary: {
2018-19: "400000INR",
2019-20: "500000INR",
2020-21: "650000INR"
},
address: {
locality: {
address1: "1600 pebble road",
address2: "Nearby XYZ Bank",
},
city: "Mumbai",
state: "Maharashtra",
country: "India"
}
}