js的箭头函数等价于什么

原文:
Arrow functions bind this to the context in which you create the arrow function.

const foo = (args) => {/* code */};

is a shortcut for

const foo = (function(args) {/* code */}).bind(this));

所以说箭头函数是绑定了this的一个普通函数
这方便了异步函数的调用(有时在异步函数中调用this会导致this为null):

 const callback = someobject.somefunction.bind(someobject);
 loader.load(callback); // 成功调用some object.somefunction

 const callback = someobject.somefunction;
 loader.load(callback); // 这时候callback为null

原文地址:https://www.cnblogs.com/lyzz1314/p/14403999.html