I mean this is because your two examples aren't equivalent unfortunately. Your object assign is mutating the original object with the new property. Where as the spread is creating a new object copying properties from the two original objects. You can see the same behaviour by 1/2
-
-
-
Running this code: Object.assign({}, day, { day: 'monday' })
- Još 2 druga odgovora
Novi razgovor -
-
-
That is a very nice catch!
Hvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
-
-
Is there a reason it's done like this? Spread internally would be doing object assign right?
Hvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
Čini se da učitavanje traje već neko vrijeme.
Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.
TIL
This subject needs a blogpost. Coming soon…