delete vs undefined

Benchmark created on


Setup

let obj = {}

for (let i = 0; i < 100000; i++) {
  obj = {...obj, [i]: i}
}

Test runner

Ready to run.

Testing in
TestOps/sec
delete
for (let i = 0; i < 100000; i++) {
	delete obj[i]
}
ready
set to undefined
for (let i = 0; i < 100000; i++) {
	obj[i] = undefined
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.