10.
How can you extend an object in JavaScript?
Using the Object.assign() method.
Using the Object.create() method.
Using the spread operator ...
Using the Object.extend() method.
Correct: A
The Object.assign() method is used to copy the values of all enumerable properties from one or more source objects to a target object. It extends the target object by adding the properties and values from the source object(s). Example:
const target = { x: 10, y: 20 };
const source = { y: 40, z: 50 };
const returnedTarget = Object.assign(target, source);
console.log(target);
// output: Object { x: 10, y: 40, z: 50 }
console.log(returnedTarget === target);
// output: true