JS高階函數

    function compose(f,g){
        return function(){
            console.log(arguments);
            return f.call(null,g.apply(null,arguments));
        }
    }
    var f = function(x){return x*x};
    var g = function(x,y){return x+y};

    var sg = compose(f,g);
    console.log(sg(1,2,3));// argments [1,2,3]// 結果輸出 9 
相關文章
相關標籤/搜索