[JS 개념정리 2] call, apply, bind 메서드
·
Programming/FE
call, apply, bind 메서드는 JavaScript에서 함수의 this 값을 명시적으로 지정하고 함수를 호출하는 방법을 제공한다. Function.prototype의 메서드이므로 모든 (화살표함수를 제외한)함수에서 사용할 수 있다. call 메서드syntax: func.call(thisArg, arg1, arg2, ...)주어진 this 값과 개별적으로 제공되는 인수들로 함수를 호출function greet(greeting) { console.log(`${greeting}, ${this.name}`);}const person = { name: "Alice" };greet.call(person, "Hello"); // 출력: Hello, Alice apply 메서드syntax: func.a..