当前位置:网站首页>How the new operator works
How the new operator works
2022-06-24 03:33:00 【HZFEStudio】
Complete high frequency question bank warehouse address :https://github.com/hzfe/awesome-interview
Complete high frequency question bank reading address :https://febook.hzfe.org/
Related issues
- new What does the operator do
- new Simulation Implementation of operators
Answer key points
Constructors Object instances
new Operator by executing a custom constructor or a built-in object constructor , Generate the corresponding object instance .
In depth knowledge
1. new What does the operator do
- Create a new object in memory .
- The inside of the new object __proto__ Assigned to the constructor prototype attribute .
- Will be inside the constructor this Assigned as a new object ( namely this Point to a new object ).
- Execute the code inside the constructor ( Add properties to the new object ).
- If the constructor returns a non empty object , Returns the object . Otherwise return to this.
2. new Simulation Implementation of operators
function fakeNew() {
// Create new objects
var obj = Object.create(null);
var Constructor = [].shift.call(arguments);
// Will be the object of __proto__ Assigned to the constructor prototype attribute
obj.__proto__ = Constructor.prototype;
// Will be inside the constructor this Assign as new object
var ret = Constructor.apply(obj, arguments);
// Return to new object
return typeof ret === "object" && ret !== null ? ret : obj;
}
function Group(name, member) {
this.name = name;
this.member = member;
}
var group = fakeNew(Group, "hzfe", 17);Reference material
边栏推荐
- What is the price of the elastic public network IP bandwidth
- What is cloud desktop and how to connect to the server? What does the mainstream architecture of cloud desktop include?
- How to build glasses website what are the functions of glasses website construction
- Ligature in font design
- Hunan data security governance Summit Forum was held, and Tencent built the best practice of government enterprise data security
- Dry goods how to build a data visualization project from scratch?
- How to select a cloud game server? Which cloud game server recommends?
- New Google brain research: how does reinforcement learning learn to observe with sound?
- Applicationclientprotocol of yarn source code
- What is an edge calculator? How is the unit price of the edge calculator calculated?
猜你喜欢

Ar 3D map technology

Sorting out of key vulnerabilities identified by CMS in the peripheral management of red team (I)

Simple and beautiful weather code

Get to know MySQL database
![[summary of interview questions] zj6 redis](/img/4b/eadf66ca8d834f049f3546d348fa32.jpg)
[summary of interview questions] zj6 redis

QT creator tips
![[summary of interview questions] zj5](/img/d8/ece82f8b2479adb948ba706f6f5039.jpg)
[summary of interview questions] zj5

Community pycharm installation visual database

On Sunday, I rolled up the uni app "uview excellent UI framework"

618大促:手机品牌“神仙打架”,高端市场“谁主沉浮”?
随机推荐
ClickHouse Buffer
Grp: how to add Prometheus monitoring in GRP service?
RI Geng series: write a simple shell script, but it seems to have technical content
LeetCode 129. Find the sum of numbers from root node to leaf node
Why should I change my PC to a cloud desktop server? What are the characteristics of this server?
TRTC audio quality problem
Actual combat | how to use micro build low code to realize tolerance application
Why can't the fortress machine log in? What are the ways to solve the problem
Tke accesses the cluster through kubectl in pod
[Tencent cloud update] against 11.11! Here comes the 1.1% discount for enterprises!
2021-10-02: word search. Given an M x n two-dimensional character grid boa
LeetCode 1047. Delete all adjacent duplicates in the string
What are the functions of Fortress machine equipment
What is an edge calculator? How is the unit price of the edge calculator calculated?
Coding CD of Devops
Grp: how to gracefully shutdown a process?
Concise and practical time code
Ar 3D map technology
Simple and beautiful weather code
[congratulations] rock solid! A new generation of AMD Blackstone architecture instance is launched!