VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-handler-apply-method/

⇱ JavaScript Handler apply() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Handler apply() Method

Last Updated : 12 Jul, 2025

JavaScript handler.apply() method in JavaScript is used as a trap for a function call. The value returned by this method is used as the result of a function call through a proxy.

Syntax: 

const p = new Proxy(target, {
 apply: function(target, thisArg, argumentsList) {
 }
});

Parameters: This method accepts three parameters as mentioned above and described below: 

  • target: This parameter holds the target object.
  • thisArg: This parameter is used for the call.
  • argumentsList: This parameter contains the list as the argument and is used for the call.

Return value: This method returns any value.

Below examples illustrate the handler.apply() method in JavaScript:

Example 1: In this example, we will calculate the sum of the numbers using the handler.apply() method in JavaScript.

Output: 

27
"Calculate sum: 23, 4"
126

Example 2: In this example, we will print values using the handler.apply() method in JavaScript.

Output: 

"Geeksforgeeks"
"geeks get (Tutorial, Jobs)"
"Geeksforgeeks"
"geeks get (Knowledge, internships)"
"Geeksforgeeks"
"geeks get (Stipend, skills)"

Supported Browsers: The browsers supported by JavaScript handler.apply() method are listed below: 

  • Google Chrome 49 and above
  • Edge 12 and above
  • Firefox 18 and above
  • Opera 36 and above
  • Safari 10 and above

We have a complete list of Javascript Proxy/handler methods, to check those go through the Javascript Proxy/handler Reference article.

Comment