当前位置:网站首页>Typescript防止基类被实例化
Typescript防止基类被实例化
2022-07-28 21:36:00 【RemoteDev】
class BaseClass{
constructor() {
console.log(new.target,new.target == BaseClass);
//防止基类被实例化
if (new.target === BaseClass){
throw new Error('基类只能被继承,不能被实例化');
}
}
}
class SubClass extends BaseClass{
constructor() {
super();
}
}
//let bc = new BaseClass();//基类禁止实例化,会报错
let sc = new SubClass();边栏推荐
- Invest 145billion euros! EU 17 countries announce joint development of semiconductor technology
- 【MySQL系列】 MySQL表的增删改查(进阶)
- frontiers出版社投稿记录(附状态变化)
- [MySQL series] addition, deletion, modification and query of MySQL tables (Advanced)
- Kotlin function nesting
- WebView whitelist
- Improvement 11 of yolov5: replace backbone network C3 with lightweight network mobilenetv3
- A new paradigm of distributed deep learning programming: Global tensor
- Thesis reading (3) - googlenet of classification
- Hands on Teaching of servlet use (1)
猜你喜欢

PCA learning

sql优化常用的几种方法

Recurrent neural network (RNN)

MySQL数据库的基本概念以及MySQL8.0版本的部署(一)

Rouyi cloud platform - how to realize the launch and login functions of the project and how to create new modules

无代码开发平台通讯录导出入门教程

Retrofit Usage Summary

安全狗入选《云安全全景图2.0》多个细项

Thesis reading (1) - zfnet of classification
![[C language] implementation of three piece chess games](/img/53/7ee14e604c06fd77d65af29d6d92b8.png)
[C language] implementation of three piece chess games
随机推荐
赋能中国芯创业者!看摩尔精英如何破解中小芯片企业发展难题
MySQL foundation - data query
The applet vant webapp component is missing, and the referenced component reports an error
WebView whitelist
Basic concept of MySQL database and deployment of MySQL version 8.0 (I)
Servlet的使用手把手教学(一)
【复制】互联网术语、简称、缩写
Is 1E3 a floating point number?
Wheel 7: TCP client
Seagate released a new risc-v architecture processor: the performance of mechanical hard disk soared 3 times
弹框遮罩层「建议收藏」
Rouyi cloud platform - how to realize the launch and login functions of the project and how to create new modules
《Shortening passengers’ travel time A dynamic metro train scheduling approach using deep reinforcem》
希捷发布全新RISC-V架构处理器:机械硬盘相关性能暴涨3倍
Learning experience sharing 4: learning experience of yolov7
Will Qualcomm and MediaTek chips soon be sold, and will they surpass Huawei to become the first in China?
Mgr.exe virus caused the startup program to fail
Reading of "robust and communication efficient federated learning from non-i.i.d. data"
Wheel 6: qserialport serial port data transceiver
Kotlin function nesting