Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Accessing Object Properties with Variables

var dogs = {
  Fido: "Mutt",  Hunter: "Doberman",  Snoopie: "Beagle"
};
var myDog = "Hunter";
var myBreed = dogs[myDog];
console.log(myBreed); // "Doberman"
 
PREVIOUS NEXT
Tagged: #Accessing #Object #Properties #Variables
ADD COMMENT
Topic
Name
8+5 =