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

440 B

title localeTitle
Accessing Object Properties with Dot Notation 使用点表示法访问对象属性

使用点表示法访问对象属性

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

var testObj = { 
  "hat": "ballcap", 
  "shirt": "jersey", 
  "shoes": "cleats" 
 }; 
 
 // Only change code below this line 
 
 var hatValue = testObj.hat;      // Change this line 
 var shirtValue = testObj.shirt;    // Change this line