freeCodeCamp/guide/chinese/certifications/javascript-algorithms-and-d.../basic-javascript/accessing-object-properties.../index.md

480 B

title localeTitle
Accessing Object Properties with Bracket Notation 使用括号表示法访问对象属性

使用括号表示法访问对象属性

这是一个可能的解决方案:

var testObj = { 
  "an entree": "hamburger", 
  "my side": "veggies", 
  "the drink": "water" 
 }; 
 
 // Only change code below this line 
 
 var entreeValue = testObj["an entree"];   // Change this line 
 var drinkValue = testObj["the drink"];    // Change this line