Skip to content

Instantly share code, notes, and snippets.

@rxluz
Created January 19, 2019 08:00
Show Gist options
  • Save rxluz/a1753f30f2aba9e981dc956d4f9d9df5 to your computer and use it in GitHub Desktop.
Save rxluz/a1753f30f2aba9e981dc956d4f9d9df5 to your computer and use it in GitHub Desktop.
JS Design Patterns: Factory Functions, see more at: https://medium.com/p/2adfe878e949
const greet = name => ({
sayHello: () => `Hello ${name}!`,
sayGoodbye: () => `Goodbye ${name}!`,
});
const run = () => {
const greetRicardo = greet("Ricardo");
console.log(greetRicardo.sayHello());
console.log(greetRicardo.sayGoodbye());
};
run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment