当前位置:网站首页>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'
边栏推荐
- 【电赛训练】红外光通信装置 2013年电赛真题
- Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched
- 【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + DHT11 +NodeJs本地服务+ MySQL数据库
- In the middle of the year, where should fixed asset management go?
- Shell脚本-数组定义以及获取数组元素
- 2.2 【pytorch】torchvision.transforms
- An overview of the design of royalties and service fees of mainstream NFT market platforms
- [ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DHT11 +nodejs local service + MySQL database
- Is it safe to dig up money and make new shares
- Principles of Microcomputer - Introduction
猜你喜欢

Bird recognition app

Pain points and solutions of equipment management in large factories

队列的实现和应用
![[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

MapReduce编程基础

安装Oracle EE

2.2 【pytorch】torchvision. transforms

【检测技术课案】简易数显电子秤的设计与制作

Jetson nano installs tensorflow GPU and problem solving

Microcomputer principle - bus and its formation
随机推荐
[ESP nanny level tutorial] crazy completion chapter - Case: chemical environment system detection based on Alibaba cloud and Arduino, supporting nail robot alarm
美团2022年机试
Jetson nano installs tensorflow GPU and problem solving
I use flask to write the website "one"
Redis -- lattice connects to redis cluster
[ESP nanny level tutorial] crazy completion chapter - Case: ws2812 light control system based on Alibaba cloud, applet and Arduino
Which method is good for the management of fixed assets of small and medium-sized enterprises?
Flink面试题
[ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DS18B20 temperature sensor +nodejs local service + MySQL database
Structure de l'arbre - - - arbre binaire 2 traversée non récursive
2.2 【pytorch】torchvision. transforms
Common interview questions for embedded engineers 2-mcu_ STM32
Shell script -for loop and for int loop
Shell script echo command escape character
Serialization, listening, custom annotation
Bird recognition app
Shell脚本-变量的定义、赋值和删除
钓鱼识别app
[ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + MQ Series + nodejs local service + MySQL storage
Football and basketball game score live broadcast platform source code /app development and construction project