当前位置:网站首页>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
边栏推荐
- How does kubernetes use harbor to pull private images
- Consensus Token:web3. 0 super entrance of ecological flow
- BK3633 规格书
- 完全二叉搜索树 (30 分)
- PLC的点表(寄存器地址和点表定义)破解探测方案--方便工业互联网数据采集
- Talent Plan 学习营初体验:交流+坚持 开源协作课程学习的不二路径
- OneFlow學習筆記:從Functor到OpExprInterpreter
- Get the absolute path of the class according to the bytecode
- LeetCode_ DFS_ Medium_ 1254. Count the number of closed islands
- 请提前布局 Star Trek突破链游全新玩法,市场热度持续高涨
猜你喜欢
Strength comparison vulnerability of PHP based on hash algorithm
经典题目刷一刷
Chris LATTNER, father of llvm: the golden age of compilers
On time atom joins hands with oneos live broadcast, and the oneos system tutorial is fully launched
深度学习框架中的自动微分及高阶导数
Reference passing 1
Latex paper typesetting operation
爬虫使用xpath解析时返回为空,获取不到相应的元素的原因和解决办法
MySQL查询两张表属性值非重复的数据
资源打包关系依赖树
随机推荐
Enterprise wechat application authorization / silent login
Summary of solid problems
Go language self-study series | golang nested structure
The crawler returns null when parsing with XPath. The reason why the crawler cannot get the corresponding element and the solution
Study notes of deep learning (8)
【原创】使用System.Text.Json对Json字符串进行格式化
微信:获取单个标签所有人
企业微信应用授权/静默登录
Play with binary tree (25 points)
Flink reads MySQL and PgSQL at the same time, and the program will get stuck without logs
xctf刷题小记
1099 establish binary search tree (30 points)
数字政府建设中政务中台中的技术创新点
Taxable income
Failed to download esp32 program, prompting timeout
Illegal character in scheme name at index 0:
Failed to prepare device for development
idea打包 jar文件
共享办公室,提升入驻体验
Chris LATTNER, father of llvm: the golden age of compilers