---
title: "objectForKeyedSubscript(_:)"
framework: javascriptcore
role: symbol
role_heading: Instance Method
path: "javascriptcore/jsvalue/objectforkeyedsubscript(_:)"
---

# objectForKeyedSubscript(_:)

Returns the value’s JavaScript property named with the specified key, allowing subscript syntax.

## Declaration

```swift
func objectForKeyedSubscript(_ key: Any!) -> JSValue!
```

## Parameters

- `key`: The name of a property in the JavaScript object.

## Return Value

Return Value The value of the named property, or the JavaScript undefined value if no property exists by that name.

## Discussion

Discussion This method is equivalent to the forProperty(_:) method, but provides Objective-C subscripting support.

## See Also

### Accessing Values with Subscript Syntax

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