fork download
  1. function partial(fn) {
  2. var args = Array.prototype.slice.call(arguments);
  3. var args = args.slice(1);
  4.  
  5. return function() {
  6. var args1 = Array.prototype.slice.call(arguments);
  7. var newArgs = args.concat(args1);
  8. var j = 0;
  9. for (var i = 0; i < newArgs.length; i++) {
  10. if (newArgs[i] === undefined) {
  11. newArgs[i] = arguments[j];
  12. j++;
  13. };
  14. };
  15. var x = fn.apply(null, newArgs);
  16. return x;
  17. }
  18. }
  19.  
  20.  
  21. function test(a, b, c, d) { return 'a=' + a + ',b=' + b + ',c=' + c + ',d=' + d; }
  22. var test1_3 = partial(test, 1, undefined, undefined, 3);
  23. console.log(test1_3(5, 6));
  24. console.log(test1_3(4, 1));
Runtime error #stdin #stdout #stderr 0.48s 321856KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
js: uncaught JavaScript runtime exception: ReferenceError: "console" is not defined.