How To Read Arguments From JavaScript Functions

How To Read Arguments From JavaScript Functions

In this tutorial, you’ll learn How to read arguments from JavaScript functions. This question was asked to me during a JavaScript interview.

Off course you can read arguments from the parameters to the function. But there is a way to read all function arguments as a single object.

The keyword arguments gives you all the arguments passed into the JavaScript function.

function foo() {
  console.log(arguments)
}

foo(2,3);

You can access both the passed in parameters using the arguments object. arguments[0] and arguments[1] will give the parameters passed to the JavaScript function foo.