--- title: Reflect.apply() slug: Web/JavaScript/Reference/Global_Objects/Reflect/apply tags: - ECMAScript 2015 - JavaScript - Method - Reference - Reflect translation_of: Web/JavaScript/Reference/Global_Objects/Reflect/apply ---
Reflect.apply() 정적 메서드는 대상 함수를 주어진 매개변수로 호출합니다.
Reflect.apply(target, thisArgument, argumentsList)
targetthisArgumenttarget의 this로 사용할 값.argumentsListtarget을 호출할 때 매개변수로 전달할 배열형 객체.주어진 this 값과 매개변수로 대상 함수를 호출한 결과.
target이 호출 가능한 객체가 아니면 {{jsxref("TypeError")}}.
ES5에서는 {{jsxref("Function.prototype.apply()")}} 메서드를 사용해, 함수를 호출할 때 this 값을 지정하거나 매개변수를 배열(또는 배열형 객체)에서 넘겨줄 수 있었습니다.
Function.prototype.apply.call(Math.floor, undefined, [1.75]);
Reflect.apply() 메서드를 사용해 같은 작업을 더 쉽고 유려하게 수행할 수 있습니다.
Reflect.apply() 사용하기Reflect.apply(Math.floor, undefined, [1.75]);
// 1;
Reflect.apply(String.fromCharCode, undefined, [104, 101, 108, 108, 111]);
// "hello"
Reflect.apply(RegExp.prototype.exec, /ab/, ['confabulation']).index;
// 4
Reflect.apply(''.charAt, 'ponies', [3]);
// "i"
| Specification |
|---|
| {{SpecName('ESDraft', '#sec-reflect.apply', 'Reflect.apply')}} |
{{Compat("javascript.builtins.Reflect.apply")}}