当前位置:网站首页>Implementation of new
Implementation of new
2022-04-23 08:05:00 【Pen drawing Acacia】
1: First, an object will be created
2: Create the properties and methods above the constructor to this object
3: Put this object's __proto__ Property of a constructor protypeof
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
</title>
<script>
// alert(2423)
// console.log("423");
function Person(name,age)
{
this.name=name;
this.age=age;
}
function _New()
{
// Create an object
const obj={};
const [Person1,...arg]=[...arguments];
// Create properties and methods in the constructor for the object
var res=Person1.apply(obj,arg);
// The display prototype of the instance points to the display prototype of the constructor
obj.__proto__=Person1.prototype;
// If the constructor has its own return value , And if it's an object, we'll use this object , Otherwise, it returns the object just created
return res==='Object'?res:obj;
}
console.log(_New(Person,' Xiao Ming ',15));
</script>
</head>
<body>
</body>
</html>
版权声明
本文为[Pen drawing Acacia]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230624332845.html
边栏推荐
- Cloud computing skills competition -- Part 2 of openstack private cloud environment
- Research on system and software security (4)
- Feign source code analysis
- Reptile learning notes, learning reptile, read this article is enough
- 内网渗透系列:内网隧道之icmptunnel(jamesbarlow师傅的)
- Codeforces Round #784 (Div. 4)
- linux下mysql数据库备份与恢复(全量+增量)
- Ctf-misc learning from start to give up
- Houdini > rigid body, rigid body breaking RBD
- 《内网安全攻防:渗透测试实战指南》读书笔记(七):跨域攻击分析及防御
猜你喜欢
Unity get real geographic map application terrain notes
使用 Ingress 实现金丝雀发布
Chapter VII asset impairment
C problem of marking the position of polygons surrounded by multiple rectangles
Go语学习笔记 - 结构体 | 从零开始Go语言
Online Safe Trajectory Generation For Quadrotors Using Fast Marching Method and Bernstein Basis Poly
云计算技能大赛 -- openstack私有云环境 第二部分
About USB flash drive data prompt raw, need to format, data recovery notes
Research on software security based on NLP (I)
CTF-MISC学习之从开始到放弃
随机推荐
STO With Billing 跨公司库存转储退货
Feign source code analysis
Reptile learning notes, learning reptile, read this article is enough
SAP自建表log功能开启
内网渗透系列:内网隧道之pingtunnel
《内网安全攻防:渗透测试实战指南》读书笔记(六):域控制器安全
Internal network security attack and defense: a practical guide to penetration testing (IV): Authority improvement analysis and defense
Personality charm of high paid it workers
Dvwa 靶场练习记录
Upload labs range practice
Unity C single case mode learning review notes
从零开始完整学习机器学习和深度学习,包括理论和代码实现,主要用到scikit和MXNet,还有一些实践(kaggle上的)
Buuctf misc brush questions
MYSQL——第一章节(数据类型2)
yum源仓库本地搭建的两种方法
攻防世界MISC刷题1-50
Cloud computing skills competition -- Part 2 of openstack private cloud environment
C read INI file and write data to INI file
Houdini > variable building roads, learning process notes
Go语学习笔记 - 异常处理 | 从零开始Go语言