! vs Boolean()

Benchmark created on


Setup

const students = Array(10000000).fill().flatMap(() => [
  {
  	name: 'foo'
  },
  {
  	name: null
  }
])

Test runner

Ready to run.

Testing in
TestOps/sec
Boolean()
students.sort((s1, s2) => Boolean(s2) - Boolean(s1))
ready
!
students.sort((s1, s2) => !s1 - !s2)
ready

Revisions

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