Created
December 7, 2015 22:11
-
-
Save Ellisande/9cdfd85fc3ef6b615cec to your computer and use it in GitHub Desktop.
Object factories vs. instances
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
var Client1 = function(args){ | |
var prop1; | |
var prop2; | |
return { | |
prop1: prop1, | |
prop2: prop2 | |
} | |
} | |
//Same as | |
var Client2 = function(args){ | |
this.prop1 = ''; | |
this.prop2 = ''; | |
this.prop3 = ''; | |
} | |
//Cannot be extended using prototype | |
var clientInstance1 = Client1(); | |
//Can be extended using prototype | |
var clientInstance2 = new Client2(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment