instanceof vs property check

Benchmark created on


Preparation HTML

<script>
  (function(global) {
    function T() {
      this.type = TYPE_FLAG;
    }
    var TYPE_FLAG = {};
    T["FLAG"] = TYPE_FLAG;
    global["T"] = T;
  })(window || this);
  
  instance = new T();
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
instanceof
instance instanceof T;
ready
property check
instance.type = T.FLAG;
ready

Revisions

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