Access the myStorage object and assign the contents of the glove box property to the gloveBoxContents variable. Use bracket notation for properties with a space in their name.
代码
// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};
// Only change code below this line
var gloveBoxContents = myStorage.car.inside["glove box"]; // Change this line
介绍
257 灵活的数据结构
对象的自己属性可以通过逗号链或中括号链进行访问。
方法
练习
代码
结果显示
来源
https://www.freecodecamp.org/challenges/accessing-nested-objects