3 ms·
that's not equivalent. d.map(i => o[i] = i\*2) Will produce a new array on top of mutated data, o, in the parent scope. d.forEach(i => o[i] = i**
by weatherlight 5y ago
that's not equivalent.
d.map(i => o[i] = i\*2)
Will produce a new array on top of mutated data, o, in the parent scope.
d.forEach(i => o[i] = i**2)
would be the one-to-one equivlent
- peterthehacker 5y agoBoth mutate o. If you ignore the array returned by map then they’re equivalent.