by yankjenets · 7y ago · 0 comments
Roughly half of his examples take an array and return either a differently-sized array, or a different data structure altogether. I can’t imagine how one could argue for a map in these cases.
Otherwise I enjoyed reading this.
This pattern will probably be dominated by the time taken to filter and map, not loop iteration.
Consider this excerpt from the .map() polyfill on MDN:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
// 7. Let k be 0
k = 0;
// 8. Repeat, while k < len
while (k < len) {
// [loop body omitted]
// d. Increase k by 1.
k++;
}