7.5 函数柯里化
add = function(){ let sum = Array.from(arguments).reduce((a,b)=>{return a+b}, 0); let myAdd = function(){ for(let i of Array.from(arguments)){ sum+=i; } return myAdd } myAdd.valueOf = function(){ return sum; } return myAdd }
add = function(){ let sum = Array.from(arguments).reduce((a,b)=>{return a+b}, 0); let myAdd = function(){ for(let i of Array.from(arguments)){ sum+=i; } return myAdd } myAdd.valueOf = function(){ return sum; } return myAdd }
相关推荐