C
opying properties into an object
const
source = {
set
foo(value) {
console.log(value);
}
};
console.log(Object.getOwnPropertyDescriptor(source, 'foo'));
// { get: undefined,
// set: [Function: foo],
// enumerable: true,
// configurable: true }
const
target = {};
Object.assign(target, source);
console.log(Object.getOwnPropertyDescriptor(target, 'foo'));
// { value: undefined,
// writable: true,
// enumerable: true,
// configurable: true }