DEV Community

Discussion on: How to make functions partially applicable in JavaScript

Collapse
 
gmartigny profile image
Guillaume Martigny

If you don't care for readability, you can write it as a tiny on-liner :

const enablePartialApplication = fn => (...args) => args.length >= fn.length ? fn(...args) : enablePartialApplication(fn.bind(null, ...args));

It nice to have such power in one line.