Type Alias


hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression.


typealias JSObjectHasInstanceCallback = (JSContextRef?, JSObjectRef?, JSValueRef?, UnsafeMutablePointer<JSValueRef?>?) -> Bool



The execution context to use.


The JSObject that is the target of the 'instanceof' expression.


The JSValue being tested to determine if it is an instance of constructor.


A pointer to a JSValueRef in which to return an exception, if any.

Return Value

true if possibleInstance is an instance of constructor, otherwise false.


If you named your function HasInstance, you would declare it like this:

bool HasInstance(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);

If your callback were invoked by the JavaScript expression 'someValue instanceof myObject', constructor would be set to myObject and possibleInstance would be set to someValue.

If this callback is NULL, 'instanceof' expressions that target your object will return false.

Standard JavaScript practice calls for objects that implement the callAsConstructor callback to implement the hasInstance callback as well.

See Also


typealias JSObjectCallAsConstructorCallback

The callback invoked when an object is used as a constructor in a 'new' expression.

typealias JSObjectCallAsFunctionCallback

The callback invoked when an object is called as a function.

typealias JSObjectConvertToTypeCallback

The callback invoked when converting an object to a particular JavaScript type.

typealias JSObjectDeletePropertyCallback

The callback invoked when deleting a property.

typealias JSObjectFinalizeCallback

The callback invoked when an object is finalized (prepared for garbage collection). An object may be finalized on any thread.

typealias JSObjectGetPropertyCallback

The callback invoked when getting a property’s value.

typealias JSObjectGetPropertyNamesCallback

The callback invoked when collecting the names of an object’s properties.

typealias JSObjectHasPropertyCallback

The callback invoked when determining whether an object has a property.

typealias JSObjectInitializeCallback

The callback invoked when an object is first created.

typealias JSObjectSetPropertyCallback

The callback invoked when setting a property’s value.