Skip to content

Instantly share code, notes, and snippets.

@zaetrik
Last active May 5, 2020 12:24
Show Gist options
  • Save zaetrik/8ef328086f8271f59367f9039306dc3b to your computer and use it in GitHub Desktop.
Save zaetrik/8ef328086f8271f59367f9039306dc3b to your computer and use it in GitHub Desktop.
Function Composition
// Function composition is the process of building more complex functions from simpler ones
const add = (x: number, y: number) => x + y
const say = (x: number) => `Your number is ${x}`
// Let's compose our two functions to build something more complex
const sayAddResult = (x: number, y: number) => say(add(x, y))
sayAddResult(2, 5) // Your number is 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment