当前位置:网站首页>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'
边栏推荐
- 2.2 【pytorch】torchvision.transforms
- JS原型链
- Promise asynchronous programming
- Serialization, listening, custom annotation
- An overview of the design of royalties and service fees of mainstream NFT market platforms
- Day06 branch structure and cycle (III)
- 2.4 activation function
- pcl_ Viewer command
- js重写自己的函数
- The jar package embedded with SQLite database is deployed by changing directories on the same machine, and the newly added database records are gone
猜你喜欢

树结构---二叉树2非递归遍历

Understanding and implementation of AVL tree

Mysql 优化

2.4 activation function

Why is the Ltd independent station a Web3.0 website!
![[interview brush 101] linked list](/img/52/d159bc66c0dbc44c1282a96cf6b2fd.png)
[interview brush 101] linked list

2.3 【kaggle数据集 - dog breed 举例】数据预处理、重写Dataset、DataLoader读取数据

2.2 【pytorch】torchvision. transforms

Jetson Nano 安装TensorFlow GPU及问题解决

2.2 【pytorch】torchvision.transforms
随机推荐
Yidian Yidong helps enterprises to efficiently manage equipment and improve equipment utilization
[ESP nanny level tutorial] crazy completion chapter - Case: chemical environment system detection based on Alibaba cloud and Arduino, supporting nail robot alarm
NoSQL数据库的安装和使用
Shell script -select in loop
[ESP nanny level tutorial] crazy completion chapter - Case: ws2812 light control system based on Alibaba cloud, applet and Arduino
Summary of reptile knowledge points
Pain points and solutions of equipment management in large factories
MapReduce编程基础
[pytorch] softmax function
Structure de l'arbre - - - arbre binaire 2 traversée non récursive
How to manage fixed assets efficiently in one stop?
ESP8266 FreeRTOS开发环境搭建
R language observation log (part24) -- initialization settings
钓鱼识别app
Naoqi robot summary 28
Which method is good for the management of fixed assets of small and medium-sized enterprises?
Set the type of the input tag to number, and remove the up and down arrows
Niuke monthly race 22- collect pieces of paper
Key points of NFT supervision and overseas policies
2.2 【pytorch】torchvision.transforms