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

# setValue(_:at:)

Sets the value at the specified numeric index in the JavaScript object value.

```
func setValue(_ value: Any!, at index: Int)
```

## Parameters

`value`

The value to set at the specified index.

`index`

An index in the JavaScript object.

## Discussion

Calling this method is equivalent to using the subscript operator with a numeric subscript in JavaScript. Use it to access elements of JavaScript arrays or of objects with numerically-indexed properties.

## Topics

### Related Documentation

[`setObject(_:atIndexedSubscript:)`](/documentation/JavaScriptCore/JSValue/setObject(_:atIndexedSubscript:))

Sets the value’s JavaScript property at the specified index, allowing subscript syntax.



---

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)