docs: function instanceOf(object, klass) {
    // Handle exceptions where the target object originates from another frame.
    // This is handy for JSON parsing (amongst other things).
    
    if (typeof klass != "function") {
      throw new TypeError("Invalid 'instanceOf' operand.");
    }
  
    if (object == null) return false;
    
    /*@cc_on  
    // COM objects don't have a constructor
    if (typeof object.constructor != "function") {
      return typeOf(object) == typeof klass.prototype.valueOf();
    }
    @*/
      if (object.constructor == klass) return true;
      if (klass.ancestorOf) return klass.ancestorOf(object.constructor);
    /*@if (@_jscript_version < 5.1)
      // do nothing
    @else @*/
      if (object instanceof klass) return true;
    /*@end @*/
  
    // If the class is a base2 class then it would have passed the test above.
    if (Base.ancestorOf == klass.ancestorOf) return false;
    
    // base2 objects can only be instances of Object.
    if (Base.ancestorOf == object.constructor.ancestorOf) return klass == Object;
    
    switch (klass) {
      case Array: // This is the only troublesome one.
        return !!(typeof object == "object" && object.join && object.splice);
      case Function:
        return typeOf(object) == "function";
      case RegExp:
        return typeof object.constructor.$1 == "string";
      case Date:
        return !!object.getTimezoneOffset;
      case String:
      case Number:
      case Boolean:
        return typeOf(object) == typeof klass.prototype.valueOf();
      case Object:
        return true;
    }
    
    return false;
  }