var func = function (callback, a, b, c) {
    return callback(a, b, c);
}

var funAdd = function (a, b, c) {
    function callback(a, b, c) { return a + b + c; }
    return func(callback, a, b, c);
}

var funMul = function (a, b, c) {
    function callback(a, b, c) { return a * b * c; }
    return func(callback, a, b, c);
}

var x = 2, y = 3, z = 4;
alert(funAdd(x, y, z)); //9
alert(funMul(x, y, z)); //24

alert(func(funAdd, x, y, z)); //9
alert(func(funMul, x, y, z)); //24

posted on 2012-03-15 12:37  万一  阅读(1543)  评论(0编辑  收藏  举报