---
title: "invokeMethod(_:withArguments:)"
framework: javascriptcore
role: symbol
role_heading: Instance Method
path: "javascriptcore/jsvalue/invokemethod(_:witharguments:)"
---

# invokeMethod(_:withArguments:)

Calls the named JavaScript method on the value.

## Declaration

```swift
func invokeMethod(_ method: String!, withArguments arguments: [Any]!) -> JSValue!
```

## Parameters

- `method`: The name of a method on the value; that is, of a field whose contents are a function value.
- `arguments`: The parameters to pass to the method. The objects in this array must be other doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSValue objects or objects that can be converted to JavaScript values using the methods listed in the Creating JavaScript Values section in doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSValue.

## Return Value

Return Value The result of calling the value as a constructor, or nil if the value cannot be treated as a JavaScript constructor.

## Discussion

Discussion Calling this Objective-C method first uses the forProperty(_:) method to look up the named field of the JavaScript value. Then, JavaScriptCore treats that field’s contents as a JavaScript function and sets the JavaScript this keyword to refer to this JSValue instance.

## See Also

### Working with Function and Constructor Values

- [call(withArguments:)](javascriptcore/jsvalue/call(witharguments:).md)
- [construct(withArguments:)](javascriptcore/jsvalue/construct(witharguments:).md)
