当前位置:网站首页>JS prototype inheritance can only inherit instances, not constructors
JS prototype inheritance can only inherit instances, not constructors
2022-07-01 09:18:00 【su27_ 0101】
js The prototype inherits the disadvantages of the constructor
- modify Person The constructor will affect the subclass that inherits it
function Person(){this.sex = 'man'};
function Man(){};
Man.prototype = Person;
var m1 = new Man();
m1.sex;//'man'
// modify Person The constructor will affect the subclass that inherits it
delete Person.sex;
m1.sex;//undefined
js Prototypes inherit constructor instances to avoid disadvantages
function Person(){this.sex = 'man'};
function Man(){};
Man.prototype = new Person();
Man.prototype.construct = Man;
var m1 = new Man();
m1.sex;//'man'
// modify Person The constructor does not affect the subclass that inherits it
delete Person.sex;
m1.sex;//'man'
边栏推荐
- 【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于阿里云、小程序、Arduino的WS2812灯控系统
- Daily office consumables management solution
- Shell script -select in loop
- 2.3 【pytorch】数据预处理 torchvision.datasets.ImageFolder
- tensorrt yolov5_ trt. Py comments
- MySQL optimization
- [pytorch learning] torch device
- laravel postman 提交表单出现419错误。2020年7月6日记。
- Redis——Lettuce连接redis集群
- 记一次redis超时
猜你喜欢

Redis -- lattice connects to redis cluster

Implementation and application of queue

How to manage fixed assets efficiently in one stop?

Which method is good for the management of fixed assets of small and medium-sized enterprises?

nacos服务配置和持久化配置

3D printing Arduino four axis aircraft

Mise en œuvre simple de l'équilibrage de la charge par nacos

小鸟识别APP

2022.02.15_ Daily question leetcode six hundred and ninety
![[pytorch] softmax function](/img/97/b8ae22e8496a77e665d716cb0e9ee3.png)
[pytorch] softmax function
随机推荐
Redis——Lettuce连接redis集群
Shell script - special variables: shell $, $*, [email protected], $$$
Tree structure -- binary tree 2 non recursive traversal
2.4 激活函数
Shell script -while loop explanation
js原型陷阱
Mysql 优化
Latex插入的eps图片模糊解决方法
nacos简易实现负载均衡
树结构---二叉树2非递归遍历
Ranking list of domestic databases in February, 2022: oceanbase regained the "three consecutive increases", and gaussdb is expected to achieve the largest increase this month
[ESP nanny level tutorial] crazy completion chapter - Case: chemical environment system detection based on Alibaba cloud and Arduino, supporting nail robot alarm
pcl_ Viewer command
Which method is good for the management of fixed assets of small and medium-sized enterprises?
Yidian Yidong helps enterprises to efficiently manage equipment and improve equipment utilization
Vsync+ triple cache mechanism +choreographer
js valueOf 与 toString 区别
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于阿里云、小程序、Arduino的温湿度监控系统
Design and manufacture of simple digital display electronic scale
Databinding source code analysis