当前位置:网站首页>js原型继承仅可继承实例而非构造器
js原型继承仅可继承实例而非构造器
2022-07-01 09:13:00 【su27_0101】
js原型继承继承构造器带来的缺点
- 修改Person构造器会影响到继承他的子类
function Person(){this.sex = 'man'};
function Man(){};
Man.prototype = Person;
var m1 = new Man();
m1.sex;//'man'
// 修改Person构造器会影响到继承他的子类
delete Person.sex;
m1.sex;//undefined
js原型继承继承构造器实例避免缺点
function Person(){this.sex = 'man'};
function Man(){};
Man.prototype = new Person();
Man.prototype.construct = Man;
var m1 = new Man();
m1.sex;//'man'
// 修改Person构造器不会影响到继承他的子类
delete Person.sex;
m1.sex;//'man'
边栏推荐
- Meituan machine test in 2022
- [ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DHT11 +nodejs local service + MySQL database
- SDN_ Simple summary
- 2.3 【pytorch】数据预处理 torchvision.datasets.ImageFolder
- 2.4 activation function
- 如何高效拉齐团队认知
- 易点易动助力企业设备高效管理,提升设备利用率
- pcl_viewer命令
- Understanding and implementation of AVL tree
- Shell脚本-变量的定义、赋值和删除
猜你喜欢

Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched

jeecg 重启报40001

Mise en œuvre simple de l'équilibrage de la charge par nacos
![[pytorch] softmax function](/img/97/b8ae22e8496a77e665d716cb0e9ee3.png)
[pytorch] softmax function

FreeRTOS learning easy notes

Vsync+ triple cache mechanism +choreographer

Principle and application of single chip microcomputer timer, serial communication and interrupt system

【pytorch】nn.CrossEntropyLoss() 与 nn.NLLLoss()

I use flask to write the website "one"

Implementation and application of queue
随机推荐
pcl_ Viewer command
Ape anthropology topic 20 (the topic will be updated from time to time)
通过 代码实例 理解 浅复制 与 深复制
易点易动助力企业设备高效管理,提升设备利用率
Vsync+ triple cache mechanism +choreographer
队列的实现和应用
[ESP nanny level tutorial] crazy completion chapter - Case: gy906 infrared temperature measurement access card swiping system based on the Internet of things
Can diffusion models be regarded as an autoencoder?
Jeecg restart alarm 40001
2.3 [kaggle dataset - dog feed example] data preprocessing, rewriting dataset, dataloader reading data
Redis source code learning (29), compressed list learning, ziplist C (II)
Shell脚本-数组定义以及获取数组元素
Input标签的type设置为number,去掉上下箭头
Shell script -while loop explanation
How to launch circle of friends marketing and wechat group activities
nacos簡易實現負載均衡
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于阿里云、小程序、Arduino的温湿度监控系统
Shell脚本-echo命令 转义符
钓鱼识别app
It technology ebook collection