Skip to content

Instantly share code, notes, and snippets.

@jperasmus
Created September 13, 2017 06:50
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 jperasmus/02c10ec76aadf82614105d4fcc711540 to your computer and use it in GitHub Desktop.
Save jperasmus/02c10ec76aadf82614105d4fcc711540 to your computer and use it in GitHub Desktop.
Basic "compose" example
const double = x => x * 2;
const square = x => x * x;
const plus3 = x => x + 3;
const composedFunction = compose(double, square, plus3);
const result = composedFunction(2);
// result = 50
// 2 (plus3) => 5 (square) => 25 (double) => 50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment