Using the spread operator to create a new object using other objects is not unusual, but what happens if both objects have the same key?
TL;DR: T...
For further actions, you may consider blocking this person and/or reporting abuse
Hmm.. interesting. Typically, I only want to override the defaults if the new value is
undefined(not included in the object). If I only rely on truthy values, then I can't override a default value that istruewithfalsefor example.Anyway, this is definitely helpful to understand so you're not surprised by the behavior.
Informative article, thanks for writing!
nullish coalesce would seem appropriate here. Like this...
fruit: newValues.fruit ?? defaultValues.fruitYes, it's a great addition, and can prevent issues with falsy values, like numbers of false statement