当函数以 apply 方式调用时, 传参方式是一个由各个参数组成的数组或类数组(一个有length属性的对象),传入参数个数取决于 length 的值,例如,某个对象 args.length=3; apply 会将 args[0],args[1],args[2] 三个参数传入,如果对应的值不存在则传入了undefined.
例如:
function f(a,b,c){ console.log(a,b,c);}
f.apply(null,{0:123,1:456,2:789,length:2});//123 456 undefined ,因为 length 属性值为2,值只传入了 2 个参数
f.apply(null,{10:123,11:456,12:789,length:3});// undefined undefined undefined , 因为参数对象不存在以 0、1、2 为...