javascript柯里化

function curry(fn){
  var slice = Array.prototype.slice;
  var arr = slice.call(arguments,1);
  return function(){
    var newArr = slice.call(arguments);
    var args = newArr.concat(arr);
    return fn.apply(null,args);
  }
}
function add(){
  var icur = 0;
  for(var i=0; i <arguments.length; i++){
    icur += arguments[i],10;
  }
  return icur;
}
var number = curry(add,1)(2,3,4,5,6,7,8,9,10);
console.log(number); //55
posted @ 2014-08-05 13:41  ZeKun  阅读(145)  评论(0编辑  收藏  举报