Skip to content Skip to sidebar Skip to footer

Use All Function Arguments Without Having To Enumerate Them

I have functionWithManyArguments(arg1,...,arg15). Can I log all arguments without having to enumerate them all?

Solution 1:

Yes, You could do something like:-

functionfoo(...args) {
  console.log(...args);
}
foo(1, 2, "a")

...args are rest parameters.

Post a Comment for "Use All Function Arguments Without Having To Enumerate Them"