Test name | Executions per second |
---|---|
Instanceof | 6163606.5 Ops/sec |
isArray | 5983011.5 Ops/sec |
variable.constructor | 6175144.5 Ops/sec |
variable.constructor name | 8537536.0 Ops/sec |
var test = [1,2,3,4];
var c;
if (test instanceof Array) { c++; }
if (Array.isArray(test)) { c++; }
if (test.constructor === Array) { c++; }
if (test.constructor.name === 'Array') { c++; }