essential-vanilla-javascript-functions icon indicating copy to clipboard operation
essential-vanilla-javascript-functions copied to clipboard

Simplify array_unique

Open timmarinin opened this issue 8 years ago • 1 comments

Use Array.prototype.indexOf instead of custom key comparator.

This change probably makes function slower due to indexOf probable O(n) timing, but clarity of the code is more important than the performance in this case.

timmarinin avatar Sep 21 '17 11:09 timmarinin

indexOf will only compare the content's indices, not it's contents if those are objects, arrays or NaN. Therefore, this breaks the current functionality.

atk avatar Sep 22 '17 13:09 atk