Passing in of default values for the various properties in Object creation function : Properties : Object Oriented JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Object Oriented » Properties »

 

Passing in of default values for the various properties in Object creation function













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();







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Object Oriented
» Properties