0
나는 이것이 대상자를 가리킬 것이라고 생각했지만 실제로는 빈 대상을 가리킨다. 아무도 설명 할 수 있을까요?왜이 코드가 다음 js 코드의 빈 객체를 가리 킵니까?
var person = {
name: 'James',
birthYear: '1991',
getAge:() => new Date().getFullYear() - this.birthYear // this points to an empty object here. test in nodejs.
}
함수 선언/표현 대 [화살표 기능의 사용 가능한 복제 : 그들은 동일/exchangeable?] (http://stackoverflow.com/questions/34361379/arrow-function-vs-function-declaration-expressions-are-they-equivalent-exch) – 4castle
화살표 함수 일반 함수와 같은 방식으로 'this'를 바인딩하지 마라. 복제물을보십시오. – 4castle