Alternative to the spread operator.
TLDR: Object.assign(object, object)
I was doing some work on a serverless function and I ...
For further actions, you may consider blocking this person and/or reporting abuse
good idea :)
if we want to keep the old value of
pizza, how we do?If you just want the original value of pizza you just put the object to the right so in
Object.assign(moreFood, food)and with the spread operator you can
{...moreFood, food}this will keep both intact and create a new object with the merged keys and values
Love it thank you! Is there is there a way to do that with the spread operator as well?
Yes:
Nice post but most of us are here probably because IE doesn't support spread operators. Sadly it doesn't support Assign() either.