Mega Code Archive
Factory Paradigm
Factory functions create and return an object of a specific type.
function createObject() {
var bufObject = new Object;
bufObject.color = "red";
bufObject.doors = 4;
bufObject.showColor = function () {
alert(this.color)
};
return bufObject;
}
var myHourse1 = createObject();
var myHourse2 = createObject();