Discuss / JavaScript / 这个 this 被箭头函数绑到哪去了?

这个 this 被箭头函数绑到哪去了?

Topic source
        var obj = {
            birth: 1990,
            getAge: () => new Date().getFullYear() - this.birth
        }
        console.log(obj.getAge()); //NaN

廖雪峰

#2 Created at ... [Delete] [Delete and Lock User]

箭头函数暂时不能用作对象方法。


  • 1

Reply