SOURCE

// 参考 https://blog.csdn.net/weixin_45709829/article/details/123931582
// 箭头函数没有自身的原型对象(prototype),所以没有this
// this指向外层第一个函数的this,如果没有则指向window对象
// 间接修改:修改外层函数中的this指向,箭头函数中的this也会改变
// 箭头函数没有arguments

var id = 'Global';
var obj = {
    id: '123'
}
//普通函数
function fn1() {
    setTimeout(function () {
        console.log(this.id)
    }, 1000);
}
//箭头函数
function fn2() {
    setTimeout(() => {
        console.log(this.id)
    }, 1000);
}
//此时修改了外层函数的this,箭头函数的this也会变
// const fn3 = fn2.bind(obj)
// fn3()

var name = 'gaby'
var person = {
    name: 'gabrielle',
    say: function () {
        console.log('say hello', this.name)
    }, //普通函数
    say2: () => {
        console.log('say2 hello', this.name)
    } //箭头函数
}
person.say.call({
    name: 'Mike'
})
//直接修改箭头函数的this不生效
person.say2.call({
    name: 'Amy'
})

console 命令行工具 X clear

                    
>
console