Passing in of default values for the various properties in Object creation function : Properties « Object Oriented « JavaScript Tutorial






function createObject(sColor, iDoors) {
    var bufObject = new Object;
    bufObject.color = sColor;
    bufObject.doors = iDoors;
    bufObject.showColor = function () {
        alert(this.color)
    };

    return bufObject;
}

var myHourse1 = createObject("red", 4);
var myHourse1 = createObject("blue", 3);
myHourse1.showColor();   
myHourse2.showColor();








25.5.Properties
25.5.1.Properties of an object can be defined dynamically after its creation
25.5.2.Factory Paradigm
25.5.3.Passing in of default values for the various properties in Object creation function