Skip to content
Advertisement

Alternative syntax to access javascript function arguments

JavaScript

prints

JavaScript

Is there a way to access the actual arguments in that case?

Advertisement

Answer

I would advise against overriding the built-in arguments variable within a function definition.

You could spread the expected arguments instead using ...vargs.

JavaScript
JavaScript

Please take a look at the arguments object over at MDN for more info.

The documentation notes that if you are using ES6 syntax, you will have to spread the arguments, because the arguments do not exist inside of an arrow (lambda or anonymous) function.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement