hammerspoon Posted on 2020-06-05 http://www.hammerspoon.org/ https://github.com/greyby/hammerspoon apply 和 call 的区别123456789var obj = { name : 'linxin'}function func(firstName, lastName){ console.log(firstName + ' ' + this.name + ' ' + lastName);}func.apply(obj, ['A', 'B']); // A linxin B call 方法第一个参数也是作为函数上下文的对象,但是后面传入的是一个参数列表,而不是单个数组。 123456789var obj = { name: 'linxin'}function func(firstName, lastName) { console.log(firstName + ' ' + this.name + ' ' + lastName);}func.call(obj, 'C', 'D'); // C linxin D bind123456789function func(a, b, c) { console.log(a, b, c);}var func1 = func.bind(null,'linxin');func('A', 'B', 'C'); // A B Cfunc1('A', 'B', 'C'); // linxin A Bfunc1('B', 'C'); // linxin B Cfunc.call(null, 'linxin'); // linxin undefined undefined via https://github.com/lin-xin/blog/issues/7