Skip to content

Instantly share code, notes, and snippets.

@jtulk
Last active October 9, 2016 19:50
Show Gist options
  • Select an option

  • Save jtulk/920e4e1228d4de4bab1b30f972bebc60 to your computer and use it in GitHub Desktop.

Select an option

Save jtulk/920e4e1228d4de4bab1b30f972bebc60 to your computer and use it in GitHub Desktop.
// `num` now exists within the closure created by
// add, and will be available in any returned function
function add(num) {
// this returned function will wait for execution with an
// argument to be provided later
return function partial(otherNum){
// return the sum of the two arguments
return num + otherNum
}
}
const stepOne = add(3)
const stepTwo = stepOne(5)
console.log(stepTwo)
const combo = add(5)(10)
console.log(combo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment