当前位置:网站首页>js 原型链的深入
js 原型链的深入
2022-04-23 09:01:00 【一个博客】
原型链的学习
1、 IE11和谷歌__proto__指向的改变
//改变指向__proto__的指向
var obj1={
a:1,
b:2
}
var obj2=Object.create(obj1)//指定obj2的原型对象为obj1
console.log(obj1.__proto__)//原型链指向Object.prototype
console.log(obj2.__proto__)//原型链指向obj1
2、兼容ie11一下的强行指向问题
//兼容ie11一下的强行指向问题(我自己的ie)
//ie有原型的机制,但是没有原型链的
var obj1={
a:1,
b:2
}
var obj2=Object.create(obj1)//指定obj2的原型对象为obj1
console.log(obj1.__proto__)//原型链指向Object.prototype
console.log(obj2.__proto__)//原型链指向obj1
3、删除__proto__指向
//删除
//null:释放对象
var obj1={a:1,b:2}
obj1.__proto__=null
console.log(obj1.toString())
4、在原型中自定义方法的使用
//将首字母大写
String.prototype.shuozimudaxie=function(){
return this[0].toUpperCase()+this.slice(1)
}
var str="akjkjkjkjkjkjkjkjk".shuozimudaxie();
console.log(str);
版权声明
本文为[一个博客]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_45784582/article/details/106334834
边栏推荐
- OneFlow学习笔记:从Functor到OpExprInterpreter
- [original] use system Text. JSON formats the JSON string
- The K neighbors of each sample are obtained by packet switching
- Consensus Token:web3. 0 super entrance of ecological flow
- 搜索树判断 (25 分)
- Failed to download esp32 program, prompting timeout
- The crawler returns null when parsing with XPath. The reason why the crawler cannot get the corresponding element and the solution
- Resource packaging dependency tree
- Open services in the bottom bar of idea
- Taxable income
猜你喜欢

Matlab draw five-star red flag

The most concerned occupations after 00: civil servants ranked second. What was the first?

Use of Arthas in JVM tools

L2-022 重排链表 (25 分)(map+结构体模拟)

Multi view depth estimation by fusing single view depth probability with multi view geometry

Valgrind et kcachegrind utilisent l'analyse d'exécution

OneFlow學習筆記:從Functor到OpExprInterpreter

Harbor enterprise image management system

Introduction to matlab

PLC point table (register address and point table definition) cracking detection scheme -- convenient for industrial Internet data acquisition
随机推荐
2021 Li Hongyi's adaptive learning rate of machine learning
[58] length of the last word [leetcode]
L2-023 graph coloring problem (25 points) (graph traversal)
PCTP考试经验分享
DJ music management software pioneer DJ rekordbox
Automatic differentiation and higher order derivative in deep learning framework
完全二叉搜索树 (30 分)
How much inventory recording does the intelligent system of external call system of okcc call center need?
Go language self-study series | initialization of golang structure
Enterprise wechat application authorization / silent login
Illegal character in scheme name at index 0:
【原创】使用System.Text.Json对Json字符串进行格式化
是否同一棵二叉搜索树 (25 分)
Mini - exercice MySQL (seulement pour les débutants, pas pour les non - débutants)
Basic usage of synchronized locks
After a circle, I sorted out this set of interview questions..
Pctp test experience sharing
About CIN, scanf and getline, getchar, CIN Mixed use of getline
Share the office and improve the settled experience
Consensus Token:web3. 0 super entrance of ecological flow