Skip to content

“index” vs. function parameter: what’s the difference? #3

Open
@mathiasbynens

Description

@mathiasbynens

Question about https://github.com/TechQuery/array-unique-proposal#core-features:

While Array.prototype.unique() invoked with:

  1. no parameter, it'll work as [...new Set(array)];

  2. one index-key parameter (Number, String or Symbol), it'll get values from each array element with the key, and then deduplicates the origin array based on these values;

  3. one function parameter, it'll call this function for each array element, and then deduplicates the origin array based on these returned values.

How is 2 different from 3?

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions