Thursday, 15 May 2014

javascript - How do I access an objects key in bracket notation? -


bracket How to use spearguns object through the notation to "I'm trying to reach higher" key console log Thank you, "undefined", thank you.

  var rockSpearguns = {Sharpshooter: {Barbs: 2, weight: 10, top: "Ovrhold"}, Pokepstol: {Barb: 4, weight: 8 vivid: "shoulder"}, Xavelinjet : {Barbs: 4, weight: 12, top: "waist"}, Fayrfayr: {Barbs: 6 weight: 8, upper: "Ovrhold"}, "The Inplr": {Barbs: 1, weight: 30, high Wave: "chest"}}; Function list guns (for different strikes in guns) {// log message here console Log in ("See!" + Speargun + ", with" + ["" Huff "] +" Waffle! "); }} Catalogs (Rock Spears);  

You must obtain the context of the gun by the name of the property in this way:

  var rockSpearguns = {Sharpshooter: {Barbs: 2, weight: 10, top: "Ovrhold"}, Pokeepistl: {Barbs: 4, weight: 8, the upper "shoulder"}, Xavelinjet: {Barbs: 4, weight: 12, top: "waist"}, Pyro: {Barbajh: 6 weight: 8, upper: "overhand"}, "The Inplr": {Barbs: 1, weight: 30, wide: "Chest"} }; Functions list guns (for different parts of the guns) {// change the log message here var gun = guns [barguna]; Console.log ("See!" + Speargun + "," + Gun ["Waffle"] + "Affordable!);}}  

No comments:

Post a Comment