当前位置:网站首页>JS prototype chain
JS prototype chain
2022-04-23 09:05:00 【A blog】
Prototype chain learning
1、 IE11 And Google __proto__ Change of direction
// Change direction __proto__ The direction of
var obj1={
a:1,
b:2
}
var obj2=Object.create(obj1)// Appoint obj2 The prototype object of is obj1
console.log(obj1.__proto__)// The prototype chain points to Object.prototype
console.log(obj2.__proto__)// The prototype chain points to obj1
2、 compatible ie11 Let's point to the problem
// compatible ie11 Let's point to the problem ( My own ie)
//ie Prototype mechanism , But there is no prototype chain
var obj1={
a:1,
b:2
}
var obj2=Object.create(obj1)// Appoint obj2 The prototype object of is obj1
console.log(obj1.__proto__)// The prototype chain points to Object.prototype
console.log(obj2.__proto__)// The prototype chain points to obj1
3、 Delete __proto__ Point to
// Delete
//null: Release object
var obj1={a:1,b:2}
obj1.__proto__=null
console.log(obj1.toString())
4、 Use of custom methods in prototypes
// Capitalize the first letter
String.prototype.shuozimudaxie=function(){
return this[0].toUpperCase()+this.slice(1)
}
var str="akjkjkjkjkjkjkjkjk".shuozimudaxie();
console.log(str);
版权声明
本文为[A blog]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230901327262.html
边栏推荐
- MYCAT configuration
- The crawler returns null when parsing with XPath. The reason why the crawler cannot get the corresponding element and the solution
- L2-022 rearrange linked list (25 points) (map + structure simulation)
- I don't understand time, timestamp and time zone. Look at this article
- Correct method of calculating inference time of neural network
- 基于点云凸包的凹包获取方法
- Concave hull acquisition method based on convex hull of point cloud
- Four pictures to understand some basic usage of Matplotlib
- K210 learning notes (II) serial communication between k210 and stm32
- LeetCode_ DFS_ Medium_ 1254. Count the number of closed islands
猜你喜欢
node安装
653. 两数之和 IV - 输入 BST
Notes on xctf questions
The crawler returns null when parsing with XPath. The reason why the crawler cannot get the corresponding element and the solution
Mini - exercice MySQL (seulement pour les débutants, pas pour les non - débutants)
What is augmented reality technology? Where can it be used?
搞不懂时间、时间戳、时区,快来看这篇
ATSS(CVPR2020)
Matlab draw five-star red flag
调包求得每个样本的k个邻居
随机推荐
LeetCode396. Rotate array
MATLAB入门资料
Distributed message oriented middleware framework selection - Digital Architecture Design (7)
Summary of solid problems
Rembg split mask
Machine learning (VI) -- Bayesian classifier
数字政府建设中政务中台中的技术创新点
[indexof] [lastIndexOf] [split] [substring] usage details
LeetCode_ DFS_ Medium_ 1254. Count the number of closed islands
MYCAT configuration
The K neighbors of each sample are obtained by packet switching
Four pictures to understand some basic usage of Matplotlib
Enterprise wechat application authorization / silent login
Complete binary search tree (30 points)
Taxable income
How to read excel table to database
【SQL server速成之路】数据库的视图和游标
How does kubernetes use harbor to pull private images
Group Backpack
Error: cannot find or load main class