instanceof vs. constructor (v3)

Revision 3 of this benchmark created on


Description

Which is faster for checking whether an object is a simple array?

Preparation HTML

<script>
  function fn(){};
  var a = new fn;
  var b = {};
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Use constructor
a.constructor === fn;
ready
Use constructor
b.constructor === fn
ready
Use instanceof
a instanceof fn
ready
Use instanceof
b instanceof fn
ready

Revisions

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