JavaScript apply() method

The Javascript handler apply() method traps for a function call.

Syntax:

apply: function(target, thisArg, arguments)

Parameters:
target: It represents the target object.
thisArg: It represents this keyword for the function call.
argumentsList: The list of function parameters.

Return:
Any value.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
 var handler = function(a, b) 
{
  document.writeln('proxy: ' + a + ', ' + b);
};
var proxy = new Proxy(handler, {
  apply: function(target, thisArg, parameters)
{
	return target.apply(thisArg, parameters);
  }
});
proxy('400', '540');
</script>
</body>
</html>

Output:

proxy: 400, 540
Please Share