News for hackers. Stuff that matters.
Re:Lodash's Chain vs. Native Methods by darepublic on Friday August 27, 2021 @09:55AM (#28327837)
if you are using slice(0,5) then all the extra objects you mapped are lost and you have no reference to them.
Re:Lodash's Chain vs. Native Methods by brundolf on Friday August 27, 2021 @10:44AM (#28328469)
Not true. slice() clones-and-drops the array, but not the objects inside.
Re:Lodash's Chain vs. Native Methods by darepublic on Saturday August 28, 2021 @11:04AM (#28338607)
but map also creates a new array, and within map you are not mutating the items of the old array but creating brand new ones no? [...].map(p => ({...p, canDrink}))

^ the original items of the array are not mutated in this map callback. you could mutate them if you really wanted, i.e.

[...].map(p => {p.canDrink = p.age > 20; return p})

but that is a straight up hack.