함수 바인딩
1. 래퍼 함수 (wrapper)
let user = {
firstName: 'John',
sayHi() {
alert(`Hello, ${this.firstName}!`);
},
};
setTimeout(function () {
user.sayHi(); // Hello, John!
}, 1000);
setTimeout(() => user.sayHi(), 1000); // Hello, John!2. bind
this뿐만이 아닌 인수도 바인딩이 가능
화살표함수와 bind의 차이
Last updated