isArray vs instanceof Array

Benchmark created on


Setup

const arr = [];
const arrr = [1, 2, 3, 4];
const obj = {};
const objj = { x: 1, y: 2, z: 'a'};

Test runner

Ready to run.

Testing in
TestOps/sec
isArray
Array.isArray(arr);
Array.isArray(arrr);
Array.isArray(obj);
Array.isArray(objj);
ready
instanceof
arr instanceof Array;
arrr instanceof Array;
obj instanceof Array;
objj instanceof Array;
ready

Revisions

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