666666666666666666
class User {
constructor(id) {
this.id_ = id;
}
}
const proxy = new Proxy(User, {
construct(target, argumentsList, newTarget) {
if (argumentsList === undefined) {
throw'User cannot be instantiated without id';
} else {
return Reflect.construct(...arguments);
}
}
});
new proxy(1);
console.log('------------------------------')
new proxy();
// Uncaught User cannot be instantiated without id
是打发斯蒂芬发散
JavaScript逆战班 入门到精通
avaScript逆战班 入门到精通
JavaScript逆战班 入门到精通 [复制链接]
66666666666
66666666666
VERY GOOOOOOOOOOOD
JavaScript逆战班 入门到精通