Object.assignbeginner// Merge source into target
const target = { a: 1 }
Object.assign(target, { b: 2 }) // β { a: 1, b: 2 }Use Object.assign() to copy properties from one or more source objects into a target object.
Passing an empty object {} as the target with one source is a common way to create a shallow clone of an object.
Challenge: Implement shallowClone(obj) that returns a shallow copy of obj using Object.assign.
const orig = { a: 1, b: 2 }
const copy = shallowClone(orig)
copy === orig // β false
copy // β { a: 1, b: 2 }