Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var partial = function() {
- const fn = arguments[0];
- const slice = Array.prototype.slice;
- const args = slice.call(arguments, 1);
- // Return a function that calls fn
- return function() {
- var remainingArgs = slice.call(arguments);
- return fn.apply(this, args.concat(remainingArgs));
- }
- }
- // test case
- const add = (a, b) => a + b;
- const add3 = partial(add, 3)
- console.log(add3(1))
- console.log(add3(4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement