Skip to content

Instantly share code, notes, and snippets.

@t0dd
Created May 10, 2013 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t0dd/5553218 to your computer and use it in GitHub Desktop.
Save t0dd/5553218 to your computer and use it in GitHub Desktop.
The factory pattern. a pseudo "interface" for objects in JS.
//The Factory Pattern
var createPerson = function(firstName, lastName) {
return {
firstName : firstName,
lastName : lastName,
greet : function(){
return "Hey there " + firstName + " " + lastName;
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment