|
|
|
|
|
by RodgerTheGreat
3596 days ago
|
|
It was just the first example that came to mind to illustrate the general pattern. We could also make this particular example shorter by using your naming conventions and writing it in a more functional manner instead of mutating the list: function unique(list) {
return list.reduce((r, i) => r.includes(i) ? r : r.concat(i), []);
}
Clearer? I dunno; probably depends on the reader's background and preferences. |
|
Perhaps an example of where map/reduce is a significant improvement to the expressiveness would be appropriate for the discussion?