JS isArray Comparison (v6)

Revision 6 of this benchmark created on


Setup

var a = [];
    var b = undefined;
    var c = null;

Test runner

Ready to run.

Testing in
TestOps/sec
Object.prototype.toString
Object.prototype.toString.call(a) === '[object Array]';
Object.prototype.toString.call(b) === '[object Array]';
Object.prototype.toString.call(c) === '[object Array]';
ready
Array.isArray
Array.isArray(a);
Array.isArray(b);
Array.isArray(c);
ready
instanceof
a instanceof Array;
b instanceof Array;
c instanceof Array;
ready
.constructor === Array
a && a.constructor === Array
b && b.constructor === Array
c && c.constructor === Array
ready
typeof
typeof a === 'array';
typeof b === 'array';
typeof c === 'array';
ready
Test 6
a = [].concat(a);
b = [].concat(b);
c = [].concat(c);
ready

Revisions

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