Open yaogengzhu opened 3 years ago
借用对象的构造函数,生成一个新的对象
const obj = {a: 1}
console.log(new obj.constructor)
const origin = {};
let target = new origin.constructor();
target.a = 1;
console.log(target); // {a: 1}
console.log(origin); // {}
const origin = [];
let target = new origin.constructor();
target[0] = 1;
console.log(target);
console.log(origin);