instanceof vs isArray (v2)

Revision 2 of this benchmark created on


Setup

let inputs = [[1], {}, [3]];
let result = false;

Teardown

if (result != true) throw 'Error';

Test runner

Ready to run.

Testing in
TestOps/sec
instanceof
for (let i = 0; i < inputs.length; i++) {
  if (inputs[i] instanceof Array) result = true;
}
ready
isArray
for (let i = 0; i < inputs.length; i++) {
  if (Array.isArray(inputs[i])) result = true;
}
ready

Revisions

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