Skip to content

Instantly share code, notes, and snippets.

@Ellisande
Created December 7, 2015 22:11
Show Gist options
  • Save Ellisande/9cdfd85fc3ef6b615cec to your computer and use it in GitHub Desktop.
Save Ellisande/9cdfd85fc3ef6b615cec to your computer and use it in GitHub Desktop.
Object factories vs. instances
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