JavaScript program to clone an object:
let originalObject = {name: "John", age: 30};
let clonedObject = Object.assign({}, originalObject);
console.log(clonedObject);
Alternatively, you can use the spread operator (...
) to clone an object:
let originalObject = {name: "John", age: 30};
let clonedObject = {...originalObject};
console.log(clonedObject);