Created
February 23, 2014 19:47
-
-
Save jagoda/9176336 to your computer and use it in GitHub Desktop.
factory pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function rectangle (length, width) { | |
var rectangle = Object.create(null); | |
rectangle.area = function () { | |
return length * width; | |
}; | |
return rectangle; | |
} | |
function square (side) { | |
var rectangle = rectangle(side, side); | |
var square = Object.create(rectangle); | |
return square; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment