The first one is :
function EventHandlers() {}
EventHandlers.prototype = Object.create(null);
this._events = new EventHandlers();
The second kind :this._events = {};
2022-05-15 04:55:23【segmentfault】
The first one is :
function EventHandlers() {}
EventHandlers.prototype = Object.create(null);
this._events = new EventHandlers();
The second kind :this._events = {};
When it comes to performance, it generally refers to time , In a broad sense, it does contain space , But generally, when there is no special explanation, it only refers to time .
But there is something wrong with what the article says , This kind of writing is not similar to obj = {}
Faster than , It's the heel obj = Object.create(null)
Faster than ( The English annotation on your screenshot clearly says ). Follow obj = {}
Not at all 、 It must be obj = {}
The slowest , The reason is simple , Because the members of the prototype chain have to be copied , There are also additional costs .
In fact, you can ignore it now , The article you read should have been released very early , This is the Node.js 6.x Pre era practice , At that time V8 Not yet Object.create
Make optimization , So if you have this type, you need to use a custom empty type hacked Writing .
Actually, you're going to see Node.js 8.x Later source code , You'll find that this place has been changed back to Object.create(null)
了 .
When it comes to performance, it generally refers to time , In a broad sense, it does contain space , But generally, when there is no special explanation, it only refers to time .
But there is something wrong with what the article says , This kind of writing is not similar to obj = {}
Faster than , It's the heel obj = Object.create(null)
Faster than ( The English annotation on your screenshot clearly says ). Follow obj = {}
Not at all 、 It must be obj = {}
The slowest , The reason is simple , Because the members of the prototype chain have to be copied , There are also additional costs .
In fact, you can ignore it now , The article you read should have been released very early , This is the Node.js 6.x Pre era practice , At that time V8 Not yet Object.create
Make optimization , So if you have this type, you need to use a custom empty type hacked Writing .
Actually, you're going to see Node.js 8.x Later source code , You'll find that this place has been changed back to Object.create(null)
了 .
copyright notice
author[segmentfault],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/131/202205111331073371.html
ArcGIS JavaScript 4. Generates a rectangular buffer at the point of X
Node under window JS installation, environment configuration, setting Taobao image
Understanding of prototype and prototype object of JavaScript
How to customize the startup port of react project!
Why vue3 0 using proxy to realize data listening 2021-06-21
Front end artifact - download, configuration and use process of Charles (vase) [Mac version]
React next configures SVG loader and supports SVG configurability
React native Android phone cannot be opened after installation. Flash back!
Fetch and Axios failed to request on Android, with error messages: network request failed and network error
How to upgrade react Babel 7.1.0