object but not array check

Benchmark created on


Setup

const vals = [{}, [], null, '', 1, true]

Test runner

Ready to run.

Testing in
TestOps/sec
constructor
vals.map(obj => obj?.constructor === Object)
ready
typeof + isArray()
vals.map(obj => typeof obj === 'object' && obj !== null && !Array.isArray(obj))
ready

Revisions

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