Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
weatherlight
· 5y ago · 0 comments
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
Comments
[–]
peterthehacker
5y ago
Both mutate o. If you ignore the array returned by map then they’re equivalent.