Defining the object methods outside of the factory functions and then pointing to them : Member Function : Object Oriented JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Object Oriented » Member Function »

 

Defining the object methods outside of the factory functions and then pointing to them













function showColor() {
    alert(this.color);
}

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

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







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Object Oriented
» Member Function