Created
December 31, 2014 05:22
-
-
Save snippe/fa214cb56839f365cf07 to your computer and use it in GitHub Desktop.
Factory Function in JavaScript
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 FactoryFunction() { | |
var obj = { | |
prop3: 3, | |
prop4: 4 | |
}; | |
return obj; | |
} | |
FactoryFunction.prototype.myMethod = function () { }; | |
//returns Object. myMethod won't be available here | |
var obj3 = new FactoryFunction(); | |
//returns Object. myMethod won't be available here | |
var obj4 = FactoryFunction(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment