<!--
{
  "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/JSObjectSetPropertyAtIndex(_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:@F@JSObjectSetPropertyAtIndex"
  },
  "title" : "JSObjectSetPropertyAtIndex(_:_:_:_:_:)"
}
-->

# JSObjectSetPropertyAtIndex(_:_:_:_:_:)

Sets a property on an object by numeric index.

```
func JSObjectSetPropertyAtIndex(_ ctx: JSContextRef!, _ object: JSObjectRef!, _ propertyIndex: UInt32, _ value: JSValueRef!, _ exception: UnsafeMutablePointer<JSValueRef?>!)
```

## Parameters

`ctx`

The execution context to use.

`object`

The [`JSObjectRef`](/documentation/JavaScriptCore/JSObjectRef) with the property you want to set.

`propertyIndex`

The property’s name as a number.

`value`

A [`JSValueRef`](/documentation/JavaScriptCore/JSValueRef) to use as the property’s value.

`exception`

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

## Discussion

Calling [`JSObjectSetPropertyAtIndex(_:_:_:_:_:)`](/documentation/JavaScriptCore/JSObjectSetPropertyAtIndex(_:_:_:_:_:)) is equivalent to calling [`JSObjectSetProperty(_:_:_:_:_:_:)`](/documentation/JavaScriptCore/JSObjectSetProperty(_:_:_:_:_:_:)) with a string that contain `propertyIndex`, but [`JSObjectSetPropertyAtIndex(_:_:_:_:_:)`](/documentation/JavaScriptCore/JSObjectSetPropertyAtIndex(_:_:_:_:_:)) provides optimized access to numeric properties.

---

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)