Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Using _ as a placeholder for "this identifier exists but is not being used" has precedent in other languages and in practice, which makes it preferable IMO to most other choices. It's less about being shorter and more about signalling to the reader that this variable is deliberately being ignored.

    Of course, JS as a language makes no actual accomodation for this. We can already completely omit unused identifiers in destructuring e.g. let [,,baz] = ['foo','bar','baz'], and being able to do that in function declarations as well would make sense, e.g. someArray.filter((,index) => <whatever>). Shame we can't.

  • Custom User Avatar

    I wouldn't consider using an underscore as a parameter name any simpler than any other naming convention, but it is certainly shorter. If parameter naming length is an important design consideration for you, perhaps using the arguments object instead of named parameters would be a better solution.

  • Default User Avatar

    but wouldn't it have been simpler to put _ to ignore the first parameter?

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution