Skip to content

Instantly share code, notes, and snippets.

@hkjpotato
Last active April 8, 2017 03:10
Show Gist options
  • Save hkjpotato/112ce6c614aa470c2bb49e78d126636c to your computer and use it in GitHub Desktop.
Save hkjpotato/112ce6c614aa470c2bb49e78d126636c to your computer and use it in GitHub Desktop.
function magician(targetfn) {
var numOfArgs = targetfn.length;
return function fn() {
if (arguments.length < numOfArgs) {
return fn.bind(null, ...arguments);
} else {
return targetfn.apply(null, arguments);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment