<!--
{
  "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/JSObjectHasPropertyCallback",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:@T@JSObjectHasPropertyCallback"
  },
  "title" : "JSObjectHasPropertyCallback"
}
-->

# JSObjectHasPropertyCallback

The callback type for determining whether an object has a property.

```
typealias JSObjectHasPropertyCallback = (JSContextRef?, JSObjectRef?, JSStringRef?) -> Bool
```

## Parameters

`ctx`

The execution context to use.

`object`

The [`JSObjectRef`](/documentation/JavaScriptCore/JSObjectRef) to search for the property.

`propertyName`

A [`JSStringRef`](/documentation/JavaScriptCore/JSStringRef) that contains the name of the property to find.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if `object` has the property; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

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

```c
bool HasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
```

If this function returns <doc://com.apple.documentation/documentation/Swift/false>, the [`hasProperty`](/documentation/JavaScriptCore/JSClassDefinition/hasProperty) request forwards to the object’s statically declared properties, then its parent class chain (which includes the default object class), and then its prototype chain.

This callback enables optimization in cases where you only need to know a property’s existence, not its value, and computing its value is expensive.

If this callback is `NULL`, the system uses the [`getProperty`](/documentation/JavaScriptCore/JSClassDefinition/getProperty) callback to service [`hasProperty`](/documentation/JavaScriptCore/JSClassDefinition/hasProperty) requests.

---

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)