![]() |
VOOZH | about |
Javascript Reflect.apply() method is a standard build-in object in JavaScript which is used to call a function using the specified argument. It works similar to the Function.prototype.apply() method to call a function, but in an efficient manner and easy to understand.
Syntax:
Reflect.apply(target, thisArgument, argumentsList)
Parameters: This method accepts three parameters as mentioned above and described below:
Return Value: Calling the given Target function resulted in the specified this value and arguments.
Exceptions: A TypeError is an exception given as the result when the target is not callable.
Below examples illustrate the Reflect.apply() Method in JavaScript:
Example 1: List argument is passed and dictionary - the object is created.
Output:
{ x: 12, y: 42, z: 32 }
Example 2: In this example, the empty list argument is passed and the function is called. And the second portion contains mathematical computation, finding the minimum element from the list.
Output:
String { "GeeksforGeeks" }
5
Example 3: In this example, the list argument is passed with some values and the function is called converting the integer into character strings.
Output:
geeksforgeeks b
Supported Browsers: The browsers supported by JavaScript Reflect.apply() Method are listed below:
We have a complete list of Javascript Reflects methods, to check those go through the JavaScript Reflect Reference article.