当前位置:网站首页>Object. Create() principle, object Create() specification, handwritten object create(),Object. Create() usage
Object. Create() principle, object Create() specification, handwritten object create(),Object. Create() usage
2022-04-23 07:35:00 【XIX (procrastination)】
List of articles
1:Object.create() usage
Use an existing object to create a new object containing it , Assign the object to the prototype of the new object .
let obj = {
name:'anny'
}
let newObj = Object.create(obj);
console.log(newObj.name). // Output :anny
Attention list :
- The first parameter can only be Object Type or null, Otherwise, an error will be reported
- The second parameter is optional , Be similar to Object.defineProperties Second parameter of .
let obj = {
name:'anny'
}
let newObj = Object.create(obj,{
name:{
value:"tony",
writable:true // Is it possible to write
}
});
console.log(newObj.name) // Output tony
2:Object.create() Principle specification
2.1: standard
- Judge whether it is Object perhaps null
- Create a new object
- Point the prototype of the new object to the incoming object
- Judge the second parameter Properties It's true
- Return the newly created object
2.2: Realization
function myCreate(obj,Properties){
// Judge whether it is Object perhaps null
if(!(obj instanceof Object)&&obj!==null){
throw TypeError
}
// Create a new object ( Equivalent to new Object())
let newObj = {
}
// Point the prototype of the new object to the incoming object
newObj.__proto__ = obj;
// If the second parameter Properties It's true
if(Properties&&Properties!==undefined){
Object.defineProperties(newObj,Properties)
}
// Return the newly created object
return newObj;
}
Please do not reprint without my consent
版权声明
本文为[XIX (procrastination)]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230618084953.html
边栏推荐
- Statement of American photography technology suing Tianmu media for using volcanic engine infringement code
- Us photo cloud editing helps BiliBili upgrade its experience
- 可视化常见绘图(五)散点图
- 推导式与正则式
- 城市应急管理|城市突发事故应急通信指挥调度系统
- go iris框架实现多服务Demo:通过(监听8083端口的)服务1中的接口启动(监听8084端口的)服务2
- 按需引入vant组件
- LATEX使用
- 后台管理系统框架,总有你想要的
- 公专融合对讲机是如何实现多模式通信下的协同工作?
猜你喜欢
el-select 中v-model绑定值,数据回显只显示value,不显示label
USO technology was invited to share the technical framework and challenges of AI synthetic virtual characters at lvson2020 conference
Patrol inspection intercom communication system in power industry
Machine vision series (01) -- Overview
DMR system solution of Kaiyuan MINGTING hotel of Fengqiao University
Meishe technology launches professional video editing solution for desktop -- Meiying PC version
南方投资大厦SDC智能通信巡更管理系统
可视化常见绘图(五)散点图
Discussion on the outline of short video technology
The people of Beifeng have been taking action
随机推荐
Emergency air space integrated communication system scheme of Guangxi Power Grid
H5案例开发
连接orcale
Lead the industry trend with intelligent production! American camera intelligent video production platform unveiled at 2021 world Ultra HD Video Industry Development Conference
xdotool按键精灵
go语言映射操作
华为云MVP邮件
地铁无线对讲系统
Solution of emergency communication system for major security incidents
VIM使用
江宁医院DMR系统解决方案
重大安保事件应急通信系统解决方案
北峰油气田自组网无线通信对讲系统解决方案
el-table的数据更新后,页面中数据未更新this.$forceUpdate()无效果
Meishe helps Baidu "Duka editing" to make knowledge creation easier
Us photo cloud editing helps BiliBili upgrade its experience
免费开源充电桩物联网云平台
可视化之路(九)Arrow类详解
Beifeng communication helps Zhanjiang fire brigade build PDT wireless communication system
quill-editor图片缩放、在一个页面使用多个富文本框、quill-editor上传图片地址为服务器地址