instanceof vs. toString

Benchmark created on


Preparation HTML

<script>
  var a = [];
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
instanceof
var isArray = a instanceof Array;
ready
Object.prototype.toString
var isArray = Object.prototype.toString.call(a) == "object [Array]";
ready

Revisions

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