Script Preparation code:
x
 
var types = {
  array: [1,2,3],
  number: 123,
  string: '123',
  map: new Map([[1,1],[2,2],[3,3]]),
  set: new Set([1,2,3]),
  buffer: new ArrayBuffer([1,2,3]),
  boolean: true,
  arrow: () => {},
  function: function () {},
  object: {},
  u8: new Uint8Array(),
  u16: new Uint16Array(),
  u32: new Uint32Array(),
  i8: new Int8Array(),
  i16: new Int16Array(),
  i32: new Int32Array()
}
var keys = Object.keys(types)
Tests:
  • isArray

     
    keys.map(key => Array.isArray(types[key]) === true)
  • instanceof

     
    keys.map(key => (types[key] instanceof Array) === true)
  • Symbol.iterator

     
    keys.map(key => types[key][Symbol.iterator] !== undefined)
  • Object.prototype.toString.call

     
    keys.map(key => Object.prototype.toString.call(types[key]).slice(8, -1) == 'Array')
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    isArray
    instanceof
    Symbol.iterator
    Object.prototype.toString.call

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 Edg/94.0.992.38
Chrome 94 on Windows
View result in a separate tab
Test name Executions per second
isArray 145145.9 Ops/sec
instanceof 139957.8 Ops/sec
Symbol.iterator 87368.4 Ops/sec
Object.prototype.toString.call 94209.5 Ops/sec