Object
Description
Object is the built-in Javascript associative object model. The
simple way of defining an
Object is to encapsulate its members in a
pair of curly braces:
var myObject = {
one: 1,
name: "Foo",
oneName: function(){
return this.one + this.name;
}
};
The object can contain properties (members) of any type. There are two main
ways of defining (or setting) a member (continuing the example above):
myObject.name = "Bar";
myObject['name'] = "Bar";
var name = myObject.name;
var name = myObject['name'];
Some browsers will throw an exception if you try to access undefined
members with the period character. Use brackets instead, if you aren't
sure if a member is defined.
Members of Objects can also be iterated using the
for keyword like:
for( var item in myObject ){
console.log( item );
console.log( myObject[item] );
console.log( '---' );
}
Extended by:
Other Singleton Members
prototype = { }
Description
The
prototype member of
Object defines the instance members.
These are copied to the instance object when the
new keyword is called.