Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
{} vs new Object() vs Object.null (Delete)
(version: 1)
Comparing performance of:
{} vs new Object() vs Object.create(null)
Created:
5 months ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const SIZE = 1000; const _floor = Math.floor; const _random = Math.random; const _chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$'; function getInt(a=0,b=0x100000000){ return _floor(_random() * (b - a)) + a; } function getStr(n=8){ let str=''; let i; for(i=0;i<n;i++) str+=_chars[getInt(0,64)]; return str } const _keys = []; const _values = []; (()=>{ let i; for(i=0;i<SIZE;i++) { _keys[i] = getStr(16); _values[i] = getInt(); } })(); const obj_1 = {}; const obj_2 = new Object(); const obj_3 = Object.create(null); for(i=0;i<SIZE;i++) { obj_1[_keys[i]] = _values[i]; obj_2[_keys[i]] = _values[i]; obj_3[_keys[i]] = _values[i]; }
Tests:
{}
for(i=0;i<SIZE;i++) delete obj_1[_keys[i]]
new Object()
for(i=0;i<SIZE;i++) delete obj_2[_keys[i]]
Object.create(null)
for(i=0;i<SIZE;i++) delete obj_3[_keys[i]]
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
{}
new Object()
Object.create(null)
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser/OS:
Chrome 142 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
{}
32469.1 Ops/sec
new Object()
32776.4 Ops/sec
Object.create(null)
32845.1 Ops/sec
Related benchmarks:
Object vs Map
Mappers
reduce: spreading acc vs mutating acc
Object.values() vs Array.from(Map.values())
lodash difference with long strings
Member Access Object vs Map(string key) vs Map(object key)
Unique Instance Test
{} vs new Object() vs Object.null (Assignment)
{} vs new Object() vs Object.null (Read)
Comments
Confirm delete:
Do you really want to delete benchmark?