SOURCE

/**
 * Array.reduce(function(total, currentValue, currentIndex, arr){
 * 
 * }, initialValue);
 * reduce方法接收一个函数作为累加器,数组中的每个值(从左到右)开始缩减,最终计算为一个值。
 * 参数:
 * total	        必需。初始值, 或者计算结束后的返回值。
 * currentValue	    必需。当前元素
 * currentIndex	    可选。当前元素的索引
 * arr	            可选。当前元素所属的数组对象。
 */

var arr = [1,2,3,4,5,6];
var total = arr.reduce(function(j, i){
    return j + i;
})
console.log(total);

var arr2 = [
    {money: 10, num: 1},
    {money: 16, num: 2},
    {money: 4.5, num: 1},
    {money: 0.12, num: 10}
]
var total2 = arr2.reduce(function(total, goods){
    return total + goods.money * goods.num;
}, 0);
console.log(total2);


/**
 * Function.call(Object, param1, param2, ...)
 * call方法接收对象,Function中的this指向Object
 * 参数:
 * Object	        必需。Function中this的指向对象
 * param1	        可选。Funcation中的第一个参数
 * param2	        可选。Funcation中的第二个参数
 * ...	            可选。Funcation中的第n个参数
 */

var obj = {
    hi: 'hello',
    name: '张三',
    say: function(){
        console.log(this.hi+' '+this.name);
    },
    console: function(text){
        console.log(text);
    }
}
var obj1 = {
    hi: 'hi',
    name: '李四'
}
obj.say();
obj.say.call(obj1);
obj.console.call(obj, '这是call函数');


/**
 * Function.apply(Object, [param1, param2, ...])
 * apply方法接收对象,Function中的this指向Object
 * 参数:
 * Object	        必需。Function中this的指向对象
 * Array	        可选。Funcation中的参数列表[第一个参数, 第二个参数,第n个参数]
 */

var obj2 = {
    hi: 'hello',
    name: '张三',
    say: function(){
        console.log(this.hi+' '+this.name);
    },
    console: function(text){
        console.log(text);
    }
}
var obj3 = {
    hi: 'hi',
    name: '李四'
}
obj2.say();
obj2.say.apply(obj3);
obj2.console.apply(obj3, ['这是apply函数']);


/**
 * Function.bind(Object)
 * bind方法接收对象,Function中的this指向Object
 * 参数:
 * Object	        必需。Function中this的指向对象
 */

var obj4 = {
    hi: 'hello',
    name: '张三',
    say: function(){
        console.log(this.hi+' '+this.name);
    },
    console: function(text){
        console.log(text);
    }
}
var obj5 = {
    hi: 'hi',
    name: '李四'
}
obj4.say();
obj4.say.bind(obj5)();
console 命令行工具 X clear

                    
>
console