Array.isArray vs instanceof Array

Benchmark created by ryanve on


Description

Test speed of Array.isArray added in 1.85

Setup

var a = [1, 2, 3];
    var s = 'example';
    var f = false;

Test runner

Ready to run.

Testing in
TestOps/sec
Array.isArray
(Array.isArray(a) && (Array.isArray(s) || Array.isArray(f)));
ready
instanceof
(a instanceof Array && (s instanceof Array || f instanceof Array));
ready

Revisions

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