SHARE
TWEET

Untitled

a guest Jul 21st, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var partial = function() {
  2.       const fn = arguments[0];
  3.       const slice = Array.prototype.slice;
  4.       const args = slice.call(arguments, 1);
  5.  
  6.       // Return a function that calls fn
  7.       return function() {
  8.         var remainingArgs = slice.call(arguments);
  9.         return fn.apply(this, args.concat(remainingArgs));
  10.       }
  11.     }
  12.     // test case
  13.     const add = (a, b) => a + b;
  14.     const add3 = partial(add, 3)
  15.     console.log(add3(1))
  16.     console.log(add3(4))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top