Proposal: ignored arguments

# Dan Kaplun (9 years ago)

I'd like to gauge the feasibility of a new feature, akin to ignored values in array destructuring:

function ignoredArgument (foo,,baz) {
  return foo+baz;
}
console.log(ignoredArgument(1,2,3) === 4);

Which could replace this common idiom, alleviating the need for an unused variable:

function ignoredArgument (foo,_,baz) {
  return foo+baz;
}
console.log(ignoredArgument(1,2,3) === 4);

Does this feature make sense for a proposal? Am I missing anything?

# Isiah Meadows (9 years ago)

In my honest opinion, I don't see the benefit. Arrays are the only structure you can even do that in. And ES3 elision elements don't exist in strict mode.

As for unused arguments, I usually just see the normal arguments for the interface, some of which just happen to be unused. I'd rather know what they are regardless of if they're used, though, so it's easier to check later on if you have to fix something. It's a little more descriptive than arguments[3] (or nothing).

# Alan Johnson (9 years ago)

What about something like a bare .? Putting nothing there seems a bit error prone, but using _ non-ideal, as it clashes with the common practice of binding utility libraries to that name. For linters, it’s nice to be able to treat unused variables as an unconditional error.

# /#!/JoePea (9 years ago)

I don't see the benefit of allowing this in function definitions (why encourage bad design?), but I could see the benefit for function calls, where

function someFunk (foo, bar, baz) {...}
someFunk( 1,,3 )

would be the same as

function someFunk (foo, bar, baz) {...}
someFunk( 1, undefined, 3 )

Well, if an argument can be undefined like that then there might be bad design there too, IMO.

/#!/JoePea

# Alan Johnson (9 years ago)

A parameter in a function definition might be ignored if it’s meant to be called as a callback, but you it doesn’t care about some of the info passed in.