Y
Hacker News
new
|
ask
|
show
|
jobs
by
weatherlight
1682 days 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
1 comments
peterthehacker
1682 days ago
Both mutate o. If you ignore the array returned by map then they’re equivalent.
link