31.Properties


#1


Dot notation, with ObjectName.PropertyName

Bracket notation, with ObjectName["PropertyName"] (don't forget the quotes!)

In the editor, we have brought back our snoopy object, with a species and age property.

Hi Im stuck here dunno what I did wrong ? help?


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 age = ["snoopy.age"];
var species = snoopy.species;

Oops, try again. It looks like you didn't save snoopy's age into age!


#2

snoopy is the object instance. It is not written in the subscript.

snoopy["age"]

#3

Thannnnk u member of the programming community. Thanks a lot.


#4

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