---
title: JSObjectHasInstanceCallback
framework: javascriptcore
role: symbol
role_heading: Type Alias
path: javascriptcore/jsobjecthasinstancecallback
---

# JSObjectHasInstanceCallback

The callback type for checking whether an object is an instance of a particular type.

## Declaration

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

## Parameters

- `ctx`: The execution context to use.
- `constructor`: The doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSObjectRef that is the target of the instanceof expression.
- `possibleInstance`: The doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSValueRef to test to determine if it’s an instance of constructor.
- `exception`: A pointer to a doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSValueRef to return an exception in, if any.

## Return Value

Return Value true if possibleInstance is an instance of constructor according to the JavaScript instanceof expression; otherwise, false.

## Discussion

Discussion If you name your function HasInstance, you declare it like this: bool HasInstance(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); If the JavaScript expression someValue instanceof myObject invokes your callback, it sets constructor to myObject, and possibleInstance to someValue. If this callback is NULL, instanceof expressions that target your object return false. Standard JavaScript practice calls for objects that implement the callAsConstructor callback to implement the hasInstance callback, as well.

## See Also

### Managing Callbacks

- [initialize](javascriptcore/jsclassdefinition/initialize.md)
- [JSObjectInitializeCallback](javascriptcore/jsobjectinitializecallback.md)
- [finalize](javascriptcore/jsclassdefinition/finalize.md)
- [JSObjectFinalizeCallback](javascriptcore/jsobjectfinalizecallback.md)
- [hasProperty](javascriptcore/jsclassdefinition/hasproperty.md)
- [JSObjectHasPropertyCallback](javascriptcore/jsobjecthaspropertycallback.md)
- [getProperty](javascriptcore/jsclassdefinition/getproperty.md)
- [JSObjectGetPropertyCallback](javascriptcore/jsobjectgetpropertycallback.md)
- [setProperty](javascriptcore/jsclassdefinition/setproperty.md)
- [JSObjectSetPropertyCallback](javascriptcore/jsobjectsetpropertycallback.md)
- [deleteProperty](javascriptcore/jsclassdefinition/deleteproperty.md)
- [JSObjectDeletePropertyCallback](javascriptcore/jsobjectdeletepropertycallback.md)
- [getPropertyNames](javascriptcore/jsclassdefinition/getpropertynames.md)
- [JSObjectGetPropertyNamesCallback](javascriptcore/jsobjectgetpropertynamescallback.md)
- [callAsFunction](javascriptcore/jsclassdefinition/callasfunction.md)
