void 0 vs undefined many types

JavaScript performance comparison

Test case created by pikax

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  const loops = 100000;
  const array = [
    {},
    void 0,
    undefined,
    1,
    '22',
    ()=>{},
    new Set(),
    new Map()
  ]

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
undefined
for(let i = 0; i < loops; i++){
  for(let j = 0; j< array.length; j++){
    const eq = undefined === array[j]
  }
}
pending…
void 0
for(let i = 0; i < loops; i++){
  for(let j = 0; j< array.length; j++){
    const eq = void 0 === array[j]
  }
}
pending…

Compare results of other browsers

Revisions

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

0 Comments