0

Suppose we have a function(a, b, c, d, e...){console.log(a,b,c,d,e)}

This will console.log inline the variables a,b,c,d,e but if the function were to have argument f passed to it (or more arguments) it would not be logged.

The following will log everything:

console.log(arguments) but it is displayed as a Arguments[] object.

I have also tried:

for (let i = 0; i < arguments.length; i++) {
        console.log(arguments[i]);
    }

Which will log every argument but each on a new line. Is it possible to console.log all arguments inline when the number of arguments is arbitrary?

1 Answer 1

2

Spread the arguments into the console.log call:

function(a, b, c, d, e){
  console.log(...arguments);
}

Or, use rest parameters

function(...args){
  console.log(...args);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.