JS isArray Comparison (v5)

Revision 5 of this benchmark created by Timoteo 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

Revisions

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