Created
May 13, 2016 19:34
-
-
Save kirankumaramruthaluri/2cdac035e4d6d77c28c35ace003cfdf2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Creating multiple constructors @ each instance | |
* @constrctor | |
* / | |
function Foobar(foobar) { | |
this.foobar = foobar; | |
} | |
Foobar.prototype = { | |
foobar: null | |
}; | |
Foobar.fromComponents = function(foo, bar) { | |
var foobar = foo + bar; | |
// this will make ths constructor to re-instantiate | |
return new this(foobar); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment