docs:programming:javascript:objects

Objects

  • objects are created with the “new” keyword
  • constructors for objects are simply functions
  • the “this” keyword indicates the current instance of the object
  • property variables can be defined within the function, but are not required to be, and can be added at any time
var dog = new Object();
dog.name = "fido";
dog.weight = 50;
dog.color = "Brown";
function animal(){
}
 
var dog = new animal();
function animal(name, weight, color){
	this.name = name;
	this.weight = weight;
	this.color = color;
}
 
var dog = new animal("fido", 50, "Brown");
var dog = {name:"fido", weight:50, color:"Brown};
  • docs/programming/javascript/objects.txt
  • Last modified: 2008/08/03 00:25
  • by 127.0.0.1