---
title: JSObjectHasPropertyCallback
framework: javascriptcore
role: symbol
role_heading: Type Alias
path: javascriptcore/jsobjecthaspropertycallback
---

# JSObjectHasPropertyCallback

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

## Declaration

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

## Parameters

- `ctx`: The execution context to use.
- `object`: The doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSObjectRef to search for the property.
- `propertyName`: A doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSStringRef that contains the name of the property to find.

## Return Value

Return Value true if object has the property; otherwise, false.

## Discussion

Discussion If you name your function HasProperty, you declare it like this: bool HasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); If this function returns false, the 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 callback to service hasProperty requests.

## 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)
- [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)
- [JSObjectCallAsFunctionCallback](javascriptcore/jsobjectcallasfunctioncallback.md)
