---
title: "setValue(_:forProperty:)"
framework: javascriptcore
role: symbol
role_heading: Instance Method
path: "javascriptcore/jsvalue/setvalue(_:forproperty:)"
---

# setValue(_:forProperty:)

Sets the value of the named property in the JavaScript object value.

## Declaration

```swift
func setValue(_ value: Any!, forProperty property: Any!)
```

```swift
func setValue(_ value: Any!, forProperty property: String!)
```

## Parameters

- `value`: The value to set for the named property.
- `property`: The name of a property in the JavaScript object.

## Discussion

Discussion Calling this method is equivalent to using the subscript operator with a string subscript in JavaScript. Use it to set or create fields or properties in JavaScript objects.

## Topics

### Related Documentation

- [setObject(_:forKeyedSubscript:)](javascriptcore/jsvalue/setobject(_:forkeyedsubscript:).md)

## See Also

### Working with Container Values

- [defineProperty(_:descriptor:)](javascriptcore/jsvalue/defineproperty(_:descriptor:).md)
- [hasProperty(_:)](javascriptcore/jsvalue/hasproperty(_:).md)
- [deleteProperty(_:)](javascriptcore/jsvalue/deleteproperty(_:).md)
- [atIndex(_:)](javascriptcore/jsvalue/atindex(_:).md)
- [setValue(_:at:)](javascriptcore/jsvalue/setvalue(_:at:).md)
- [forProperty(_:)](javascriptcore/jsvalue/forproperty(_:).md)
- [JSValueProperty](javascriptcore/jsvalueproperty.md)
