DEV Community

Discussion on: Understanding Rest Parameter Syntax

Collapse
 
laurieontech profile image
Laurie

The first example is using the rest parameter, which is what the article is meant to explain.

The second example would not apply for the example above since it's only passing integers. It would work if the example looked like this though.

function testRest({ first }) {
  console.log(first);
}
testRest({ first: 1 });

However, the "infinite" number of arguments use case is not handled unless the arguments in question are already in an object and their key names are known. It's a very different piece of syntax.