test array length

Benchmark created on


Setup

const array = new Array(1000).fill(0);

Test runner

Ready to run.

Testing in
TestOps/sec
Opérateur arithémtique (>)

  for (let i = 0; i < 10000; i++) {
      if (array.length > 0) {
          console.log(i)
      }
  }
  
ready
Opérateur de comparaison (!==)

  for (let i = 0; i < 10000; i++) {
      if (array.length !== 0) {
          console.log(i)
      }
  }
ready
Length

  for (let i = 0; i < 10000; i++) {
      if (array.length) {
          console.log(i)
      }
  }
ready
Double négation (!!)

  for (let i = 0; i < 10000; i++) {
      if (!!array.length) {
          console.log(i)
      }
  }
ready

Revisions

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