- this指向的区别
箭头函数中的this是在定义时就决定的,而且不可修改(call,apply,bind)
箭头函数的this指向定义时候,外层第一个普通函数的this
- 箭头函数不能new,不能当做构造函数。
- 箭头函数没有prototype
- 箭头函数没有arguments
- sdfsd
let obj = {
a: function(){
console.log(this);
},
b: () => {
console.log(this);
}
}
obj.a();
obj.b();
let obj6 = {
run: function(){
return function(){
console.log(this);
}
},
fun: function(){
return () => {
console.log(this);
}
}
}
obj6.run()();
obj6.fun()();
obj6.run().call(obj6);
obj6.fun().call(window);
let bun = () => {
return 'ssss';
}
console.log(bun.prototype);
let fun = function() {
console.log(arguments);
}
fun(1);
let run = () => {
console.log(arguments);
}
run();