isDate - duck typing vs. instanceof (v3)

Revision 3 of this benchmark created on


Description

This test is motivated by the use of duck typing in the current underscore.js implementation for _.isType() functions.

Preparation HTML

<script>
  var obj0 = new Date(),
      obj1 = {
    a: 5,
    b: 7
      },
      obj2 = new Date(2009, 0, 5),
      obj3 = 8;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
duck typing
!! (obj0 && obj0.getTimezoneOffset && obj0.setUTCFullYear)
ready
instanceof
obj0 instanceof Date
ready
duck typing 2
obj0 && obj0.getTimezoneOffset && obj0.setUTCFullYear
ready

Revisions

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