Skip to content

Instantly share code, notes, and snippets.

@princefishthrower
Last active October 14, 2020 16:16
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 princefishthrower/380ac13357dbabd2d65031b15bc94a02 to your computer and use it in GitHub Desktop.
Save princefishthrower/380ac13357dbabd2d65031b15bc94a02 to your computer and use it in GitHub Desktop.
partial.js - partially evaluate a function
// partial.js - partially evaluate a function
// taken from https://egghead.io/lessons/react-pass-data-to-event-handlers-with-partial-function-application
// usage:
// const addTwo(a, b) => a + b;
// const partialAddTwo = partial(addTwo, 10);
// const sum = partialAddTwo(5);
// console.log(sum);
// 15
export const partial(fn, ...args) => fn.bind(null, ...args);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment