You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Object.assign() takes as its first argument the target object to assign properties to. All of the other arguments are source values/objects.
The spread syntax is equivalent to passing each value of the array to the function as separate arguments
Objects in javascript are passed/assigned by reference
With all of this in mind, the Object.assign() is equivalent to:
constobj=Object.assign(array[0],last);
So the properties of last are copied to array[0]. Since both have the same, single property, that means the value of 5 in array[0] is overwritten with the value of 7 from last.
The text was updated successfully, but these errors were encountered: