<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "JavaScriptCore",
  "identifier" : "/documentation/JavaScriptCore/JSObjectHasInstanceCallback",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:@T@JSObjectHasInstanceCallback"
  },
  "title" : "JSObjectHasInstanceCallback"
}
-->

# JSObjectHasInstanceCallback

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

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

## Parameters

`ctx`

The execution context to use.

`constructor`

The [`JSObjectRef`](/documentation/JavaScriptCore/JSObjectRef) that is the target of the `instanceof` expression.

`possibleInstance`

The [`JSValueRef`](/documentation/JavaScriptCore/JSValueRef) to test to determine if it’s an instance of `constructor`.

`exception`

A pointer to a [`JSValueRef`](/documentation/JavaScriptCore/JSValueRef) to return an exception in, if any.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if `possibleInstance` is an instance of `constructor` according to the JavaScript `instanceof` expression; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

If you name your function `HasInstance`, you declare it like this:

```c
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 <doc://com.apple.documentation/documentation/Swift/false>.

Standard JavaScript practice calls for objects that implement the [`callAsConstructor`](/documentation/JavaScriptCore/JSClassDefinition/callAsConstructor) callback to implement the [`hasInstance`](/documentation/JavaScriptCore/JSClassDefinition/hasInstance) callback, as well.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)