class Copy {
static deepClone(orig) {
const copy = Object.create(Object.getPrototypeOf(orig));
return this.copyOwnPropertiesFrom(copy, orig);
}
static copyOwnPropertiesFrom(target, source) {
Object.getOwnPropertyNames(source).forEach((propKey) => {
const desc = Object.getOwnPropertyDescriptor(source, propKey);
Object.defineProperty(target, propKey, desc);
});
return target;
}
}
Copy.deepClone(window) // 深拷贝window/this