<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "JavaScriptCore",
  "identifier" : "/documentation/JavaScriptCore/JSObjectHasPropertyForKey(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:@F@JSObjectHasPropertyForKey"
  },
  "title" : "JSObjectHasPropertyForKey(_:_:_:_:)"
}
-->

# JSObjectHasPropertyForKey(_:_:_:_:)

Tests whether an object has the specified property using a JavaScript value as the property key.

```
func JSObjectHasPropertyForKey(_ ctx: JSContextRef!, _ object: JSObjectRef!, _ propertyKey: JSValueRef!, _ exception: UnsafeMutablePointer<JSValueRef?>!) -> Bool
```

## Parameters

`ctx`

The execution context to use.

`object`

The [`JSObjectRef`](/documentation/JavaScriptCore/JSObjectRef) to test.

`propertyKey`

A [`JSValueRef`](/documentation/JavaScriptCore/JSValueRef) that contains the property key to use when looking up the property.

`exception`

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

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the object has a property with a name that matches `propertyKey`; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

This function is the same as performing `propertyKey in object` from JavaScript.

---

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)