apply(point ,array)
参数1 : this指向
参数2 : 数组 (数组里的每个数传递给被调用的方法进行处理,参数平铺)
例1
Math.max(),参数不支持数组形式
var arr = 1,2,3,4,5,6;
Math.max.apply(null,arr);
例2
var arr1 = [1,2,3,4,5];
var arr2 = ["a","b","c","d","e"];
arr1.push(arr2);
// 未使用apply,arr2作为一个整体push进去
console.log(arr1); //[1,2,3,4,5,["a","b","c","d","e"]]
var arr3 = [1,1,1,1,1];
var arr4 = ["q","q","q","q","q"];
[].push.apply(arr3 ,arr4 );
console.log(arr3); //[1, 1, 1, 1, 1, "q", "q", "q", "q", "q"]
var arr = []
fn(1, 2, 3, 4)
function fn(a, b, c, d) {
arr.push.apply(arr,arguments)
console.log(arr);
}
// 参数一.谁调用这个方法
// 参数二.传入方法的参数
call(point ,ags1,ags2,ags3,ags4)
与apply用法相同,就是第二个参数不同