Java Reference
In-Depth Information
superman["real" + " " + "name"] // the property is built
string concatenation
<< "Clarke Kent"
If you try to access a property that doesn't exist, undefined will be returned:
<< undefined
Calling Methods
To call an object's method we can also use dot or bracket notation. Calling a method is the
same as invoking a function, so parentheses need to be placed after the method name:
<< "Up, up and away!"
<< "Up, up and away!"
Checking if Properties or Methods Exist
The in operator can be used to check whether an object has a particular property. So, for
example, we can check if the superman object has a property called city using this
"city" in superman
<< false
Alternatively, you could also check to see if the property or method doesn't return un-
defined : !== undefined
<< false
Search WWH ::

Custom Search