Post by ARYAN SAINI

ARYAN SAINI
@09aryan • #thought  • 8mo (edited)

What is ''arguments" object in JavaScript functions ?

Inside every function, an 'arguments' object is accessible. It is an Array-like object that contains the values of the arguments passed to the function.


Explanation of the provided example in the attached image:-

add is called with arguments 1 and 2. So arguments[0] contains the value 1 and arguments[1] contains the value 2.


With the arguments object, you can access the passed arguments without parameters. This is useful, for example, if you want to write a function that processes an arbitrary number of arguments.

Your upvotes and feedback are welcome!

Words have more power than we think. Be kind.