箭头函数
文章目录
跟普通函数一样,箭头函数也会被提前声明
console.log(fun(5, 4));
function fun(c, d) {
return c - d;
}
let fun = (a, b) => {
return a + b;
}
//Uncaught SyntaxError: Identifier 'fun' has already been declared
跟普通函数不一样的地方:
1.this静态声明
普通函数this指向调用它的对象(无则window); 箭头函数无this, 跟声明时的作用域共this, 因此call,apply这种方法无法改变箭头函数的this指向
let fun1 = function(c, d) {
console.log