Fastest array check (v3)

Revision 3 of this benchmark created by caitlin on


Setup

var arr = [1];
    var notArr = {
      1: 1,
      length: 1,
      splice: function() {}
    };

Test runner

Ready to run.

Testing in
TestOps/sec
Classic tostring
if (Object.prototype.toString.call(arr).search(/Array/i) >= 0) {}
ready
Classic tostring array-like
if (Object.prototype.toString.call(notArr).search(/Array/i) >= 0) {}
ready
Modern isArray
if (Array.isArray(arr)) {}
ready
Modern isArray array-like
if (Array.isArray(notArr)) {}
ready
Property check
if (arr.length && arr.splice) {}
ready
Property check array-like
if (notArr.length && notArr.splice) {}
ready

Revisions

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