Jurassic.Library.FunctionInstance.HasInstance C# (CSharp) Method

HasInstance() public method

Determines whether the given object inherits from this function. More precisely, it checks whether the prototype chain of the object contains the prototype property of this function. Used by the "instanceof" operator.
public HasInstance ( object instance ) : bool
instance object The instance to check.
return bool
        public virtual bool HasInstance(object instance)
        {
            if ((instance is ObjectInstance) == false)
                return false;
            object functionPrototype = this["prototype"];
            if ((functionPrototype is ObjectInstance) == false)
                throw new JavaScriptException(this.Engine, ErrorType.TypeError, "Function has non-object prototype in instanceof check");
            var instancePrototype = ((ObjectInstance)instance).Prototype;
            while (instancePrototype != null)
            {
                if (instancePrototype == functionPrototype)
                    return true;
                instancePrototype = instancePrototype.Prototype;
            }
            return false;
        }