当前位置:网站首页>Typescript prevents base classes from being instantiated
Typescript prevents base classes from being instantiated
2022-07-28 23:28:00 【RemoteDev】
class BaseClass{
constructor() {
console.log(new.target,new.target == BaseClass);
// Prevent base classes from being instantiated
if (new.target === BaseClass){
throw new Error(' Base classes can only be inherited , Can't be instantiated ');
}
}
}
class SubClass extends BaseClass{
constructor() {
super();
}
}
//let bc = new BaseClass();// Base class instantiation prohibited , Will report a mistake
let sc = new SubClass();
边栏推荐
- Inheritance in swift
- 华为无线设备配置利用WDS技术部署WLAN业务
- Leetcode 199. right view of binary tree
- [database]
- Seagate released a new risc-v architecture processor: the performance of mechanical hard disk soared 3 times
- Source code analysis of kotlin collaborative process startup
- [filter tracking] target tracking based on EKF, TDOA and frequency difference positioning with matlab code
- Input element label
- MySQL常用的日期时间函数
- 通过Wi-Fi 7实现极高吞吐量——洞察下一代Wi-Fi物理层
猜你喜欢
Messages from students participating in the competition: memories of the 17th session
No code development platform management background tutorial
安全狗入选《云安全全景图2.0》多个细项
How strong is this glue?
Arduino UNO驱动合宙1.8‘TFT SPI屏幕示例演示(含资料包)
Assembly analysis swift polymorphism principle
The safety dog has been selected into many details of cloud security panorama 2.0
当初的“你“为什么做测试/开发程序员?自己存在的价值......
6 open source tutorials of super conscience!
xshell7,xftp7个人免费版官方下载,无需破解,免激活,下载即可使用
随机推荐
[copy] Internet terms, abbreviations, abbreviations
【滤波跟踪】基于EKF、时差和频差定位实现目标跟踪附matlab代码
参加竞赛同学们的留言 : 第十七届的记忆
【图像分割】基于方向谷形检测实现静脉纹路分割附MATLAB代码
Input element label
The safety dog has been selected into many details of cloud security panorama 2.0
Pgbench benchmark PostgreSQL
Media query adaptation
Empowering Chinese core entrepreneurs! See how Moore elite solves the development problems of small and medium-sized chip Enterprises
Typescript防止基类被实例化
业界首创云原生安全检测双模型!安全狗重磅报告亮相数字中国建设峰会
Bullet frame mask layer "recommended collection"
NVM use... Exit status garbled
【MongoDB】MongoDB数据库的基础使用,特殊情况以及Mongoose的安装和创建流程(含有Mongoose固定版本安装)
WebView optimization
Elements in the middle (one article is enough)
Apk signature.Apk version information
Assembly analysis swift polymorphism principle
[C language] implementation of three piece chess games
[database]