Skip to main content
0:00est. 3 min

Chapter 48- Framework Aside (Function Factories)

Notes

Factory is function which returns and makes other things for app
Example 1
function makeGreeting(language){
return function(firstname, lastname){
if(language=='en'){
console.log("Hello" + firstname + lastname);
}
if(language=='es'){
console.log("Hola" + firstname + lastname);
}
}
}

var greetEnglish = makeGreeting(‘en');
var greetSpanish = makeGreeting(‘es');
greetEnglish(‘John','Doe');
greetSpanish(‘John','Doe');