当前位置:网站首页>js原型和原型链及原型继承
js原型和原型链及原型继承
2022-08-11 01:41:00 【猿码当先】
js中,每当定义一个对象时,对象中都会包含一些预定义的属性。每个函数对象都有一个prototype属性,这个属性指向函数的原型对象。每个实例对象都有一个"_proto_"属性,这个属性指向原型对象。
1.所有函数、对象都有原型。
2.所有构造函数都有prototype属性,用来存放公共方法。
3.所有实例化对象都有_proto_属性,存放公共方法。
4.constructor 构造方法(原型对象创建的构造函数)
原型对象就是一个普通的对象,就是构造函数.prototype(见下图)。原型对象都会有一个constructor属性,这个属性又会指向prototype所在的函数(构造函数)。

图中红色的就是原型链。
当查找一个对象的属性时,js会向上遍历原型链,直到找到给定名称的属性为止,如果查找到达原型链的顶部 ,也就是 Object.prototype ,但是仍然没有找到指定的属性,就会返回 undefined

边栏推荐
- 2022年PMP报考指南
- OpenWrt之opkg详解
- 软件测试面试题:在频繁的版本发布中,如何回归测试?
- 88Q2110 access C45 phy address through C22
- 第二课第一周第4-6节 医学预后案例欣赏+作业解析
- MySQL基础篇【第一篇】| 数据库概述及数据准备、常用命令、查看表结构步骤
- Sigma development pays attention to details
- [Server data recovery] Data recovery case of lvm information and VXFS file system corruption caused by raid5 crash
- 软件测试面试题:对 RUP,CMM,CMMI,XP,PSP,TSP 的认识?
- 【微波工程学习记录1】功率分配器和定向耦合器
猜你喜欢

联盛德W801系列6-从微信小程序的角度来分析W801的蓝牙通信源码(indicate方式)

双机热备综合实验(VRRP+OSPF+VTP+NAT+DHCP+PVSTP+单臂路由)

年薪30W,BAT抢着要,懂面试技巧的测试人究竟多吃香?

Two-dimensional array combat project -------- "Minesweeper Game"

MySQL八股文背诵版(续)

This Thursday evening at 19:00, Lesson 5 of the sixth phase of knowledge empowerment丨OpenHarmony WiFi subsystem

络达开发---自定义Timer的实现

数据库数据采集利器FlinkCDC

【Video】Report Sharing | 2021 Insurance Industry Digital Insights

MSTP - Multiple Spanning Tree (Case + Configuration)
随机推荐
Data Filters in ABP
php 判断数组是否为多维数组
联盛德W801系列5-微信小程序与W801蓝牙通信例程(阅读笔记)
软件测试面试题:什么是α测试,β测试?
如何防止离职员工把企业文件拷贝带走?法律+技术,4步走
Lianshengde W801 series 6-Analyze the Bluetooth communication source code of W801 from the perspective of WeChat applet (indicate method)
apache+PHP+MySQL+word press, page error when installing word press?
连流量染色都没有,你说要搞微服务?
[ASM] The relationship between the role of the bytecode operation ClassWriter COMPUTE_FRAMES and visitMaxs
nvidia-smi详解
zerorpc:async=True can be written as **{“async“: True}
FPGA learning column (xinlinx) serial communication -
Dual machine thermal for comprehensive experiment (VRRP + OSPF + + NAT + DHCP + VTP PVSTP + single-arm routing)
深度解析:什么是太爱速M抢单模式?
【websocket】
Still using Xshell?You are out, recommend a more modern terminal connection tool, easy to use!
SystemVerilog: 验证知识点点滴滴
导入数据包上传宝贝提示“类目不能为空”是什么原因,怎么解决?
21. Aliyun oss
Data Analysis Interview Manual "SQL"