Factory Paradigm : Properties : Object Oriented JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Object Oriented » Properties »

 

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







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Object Oriented
» Properties