Abstract Factory
Creates an instance of several families of classes

EX:
var fromPrototype = function(prototype, object) {
var newObject = Object.create(prototype);
for (var prop in object) {
if (object.hasOwnProperty(prop)) {
newObject[prop] = object[prop];
}
}
return newObject;
};
var Ingredients = {
createDough: function() {
return 'generic dough';
},
createSauce: function() {
return 'generic sauce';
},
createCrust: function() {
return 'generic crust';
}
};
Ingredients.createChicagoStyle = function() {
return fromPrototype(Ingredients, {
createDough: function() {
return 'thick, heavy dough';
},
createSauce: function() {
return 'rich marinara';
},
createCrust: function() {
return 'deep-dish';
}
});
};
Ingredients.createCaliforniaStyle = function() {
return fromPrototype(Ingredients, {
createDough: function() {
return 'light, fluffy dough';
},
createSauce: function() {
return 'tangy red sauce';
},
createCrust: function() {
return 'thin and crispy';
}
});
};
var californiaIngredients = Ingredients.createCaliforniaStyle();
californiaIngredients.createCrust(); // returns 'thin and crispy';Last updated