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:
Related in same category :
-
-
-
-
-
-
|