Table of Contents

Objects

Creating an object

using Object()

var dog = new Object();
dog.name = "fido";
dog.weight = 50;
dog.color = "Brown";

using a constructor

function animal(){
}
 
var dog = new animal();

using a constructor with arguments

function animal(name, weight, color){
	this.name = name;
	this.weight = weight;
	this.color = color;
}
 
var dog = new animal("fido", 50, "Brown");

using shortcut brackets

var dog = {name:"fido", weight:50, color:"Brown};

See Also