Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
{} vs new Object() vs Object.null (Assignment)
(version: 4)
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(); } })();
Tests:
{}
const obj = {}; for(i=0;i<SIZE;i++) obj[_keys[i]] = _values[i];
new Object()
const obj = new Object() for(i=0;i<SIZE;i++) obj[_keys[i]] = _values[i];
Object.create(null)
const obj = Object.create(null); for(i=0;i<SIZE;i++) obj[_keys[i]] = _values[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:
2 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0
Browser/OS:
Firefox 147 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
{}
8900.9 Ops/sec
new Object()
9367.7 Ops/sec
Object.create(null)
9361.8 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 (Read)
{} vs new Object() vs Object.null (Delete)
Comments
Confirm delete:
Do you really want to delete benchmark?