Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vlad-bezden/96ed3940b2dcdbe44ff2 to your computer and use it in GitHub Desktop.
Save vlad-bezden/96ed3940b2dcdbe44ff2 to your computer and use it in GitHub Desktop.
Function Composition versus Inheritance
'use strict';
const formalGreeting = (name) => `Hello ${name}`;
const casualGreeting = (name) => `Sup ${name}`;
const male = (name) => `Mr. ${name}`;
const female = (name) => `Mrs. ${name}`;
const doctor = (name) => `Dr. ${name}`;
const phd = (name) => `${name} PhD`;
const md = (name) => `${name} M.D.`;
// usege examle
const chetGreeting = formalGreeting(male(phd('Chet')));
console.log(chetGreeting);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment