Bug? in Introduction to Objects I, pt 31



I passed the exercise, but isn't my dot notation for snoopy's species only passing because of some glitch or bug or is it actually correct? just trying to learn here and I would like to know for sure before I move on. Thanks!

var snoopy = new Object();
snoopy.species = "beagle";
snoopy.age = 10;

// save Snoopy's age and species into variables
// use dot notation for snoopy's species
var species = "beagle";
// use bracket notation for snoopy's age
var age = snoopy['age'];


Read more here, but your code is correct. To cite the page if you don't want to read it in-depth:

Properties of JavaScript objects can also be accessed or set using a bracket notation (for more details see property accessors). Objects are sometimes called associative arrays, since each property is associated with a string value that can be used to access it.

I don't know what more to say on this theme, because this is really good explanation. If you want more info, let me know.


Thanks a lot Igor. I guess I was simply skeptical that it was that answer and that I came up with it without a lot of steam coming out of my ears, as per usual. I appreciate you responding.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.