当前位置:网站首页>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'
边栏推荐
- Shell脚本-read命令:读取从键盘输入的数据
- Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched
- [ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + MQ Series + nodejs local service + MySQL storage
- Shell script case in and regular expressions
- Shell脚本-echo命令 转义符
- Meituan machine test in 2022
- Leetcode daily question brushing record --540 A single element in an ordered array
- LogBack
- 2.4 activation function
- [interview brush 101] linked list
猜你喜欢
![[video game training] real topic of 2013 video game of infrared optical communication device](/img/ef/c2c45c1c6c24aed0a4e93101047372.png)
[video game training] real topic of 2013 video game of infrared optical communication device

FreeRTOS learning easy notes

Principles of Microcomputer - Introduction

PR training notes

Vsync+ triple cache mechanism +choreographer

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

Reproduced Xray - cve-2017-7921 (unauthorized access by Hikvision)

【pytorch】softmax函数

Tree structure -- binary tree 2 non recursive traversal

Why is the Ltd independent station a Web3.0 website!
随机推荐
Jeecg restart alarm 40001
3D printing Arduino four axis aircraft
Football and basketball game score live broadcast platform source code /app development and construction project
[ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DS18B20 temperature sensor +nodejs local service + MySQL database
树结构---二叉树1
Shell script echo command escape character
The jar package embedded with SQLite database is deployed by changing directories on the same machine, and the newly added database records are gone
Flink interview questions
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于阿里云和Arduino的化学环境系统检测,支持钉钉机器人告警
FreeRTOS learning easy notes
2.3 [kaggle dataset - dog feed example] data preprocessing, rewriting dataset, dataloader reading data
【pytorch】nn. Crossentropyloss() and nn NLLLoss()
MapReduce编程基础
Shell脚本-case in 和正则表达式
[ESP nanny level tutorial] crazy completion chapter - Case: temperature and humidity monitoring system based on Alibaba cloud, applet and Arduino
SDN_简单总结
Day06 branch structure and cycle (III)
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于阿里云、小程序、Arduino的温湿度监控系统
[pytorch] softmax function
2.2 【pytorch】torchvision. transforms