type detection (v4)

Revision 4 of this benchmark created by shesek on


Preparation HTML

<script>
  var subject = [1, 2, 3, 4, 5],
      toString = Object.prototype.toString;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Object.prototype.toString.call
(Object.prototype.toString.call(subject) === "[object Array]")
ready
duck typing
(typeof subject === "object" && typeof subject.join !== 'undefined' && typeof subject.length === "number")
ready
toString
(toString.call(subject) === "[object Array]")
ready

Revisions

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