<!--
{
  "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/JSValue/defineProperty(_:descriptor:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:objc(cs)JSValue(im)defineProperty:descriptor:"
  },
  "title" : "defineProperty(_:descriptor:)"
}
-->

# defineProperty(_:descriptor:)

Defines a property on the JavaScript object value or modifies a property’s definition.

```
func defineProperty(_ property: Any!, descriptor: Any!)
```

## Parameters

`property`

The name of the property to define or modify.

`descriptor`

A JavaScript object whose keys and values define the property’s behavior.

## Discussion

Calling this method is equivalent to using the `Object.defineProperty` method in JavaScript. The `descriptor` parameter has the same format required by that JavaScript method; for convenience when calling from Objective-C or Swift, you can also construct it as a dictionary with the keys listed in [Property Descriptor Keys](/documentation/JavaScriptCore/property-descriptor-keys).

The descriptor determines the behavior of the JavaScript property, and must fit one of three cases:

- Data Descriptor: Contains one or both of the keys `value` and `writable`, and optionally also contains the keys `enumerable` or `configurable`. Cannot contain the keys `get` or `set`. Use a data descriptor to create or modify the attributes of a data property on an object (replacing any existing accessor property).
- Accessor Descriptor: Contains one or both of the keys `get` or `set`, and optionally also contains the keys `enumerable` or `configurable`. Cannot contain the keys `value` and `writable`. Use an accessor descriptor to create or modify the attributes of an accessor property on an object (replacing any existing data property).
- Generic Descriptor: Contains one or both of the keys `enumerable` or `configurable`, and cannot contain any other keys. Use a genetic descriptor to modify the attributes of an existing data or accessor property, or to create a new data property.

---

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)