The JavaScript spread operator (...
) enables you to quickly copy all or part of an existing array or object into a new array or object.
const const |
The spread operator is commonly used alongside destructuring.
Assign the first and second items from numbers
to variables, and place the remaining items into a new array.
const |
The spread operator can also be used with objects.
Merge these two objects:
const
|
The non-matching properties were merged, but the matching color property was overwritten by the last object, updateMyVehicle, resulting in the color being yellow. |