<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "JavaScriptCore",
  "identifier" : "/documentation/JavaScriptCore/JSValue/invokeMethod(_:withArguments:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:objc(cs)JSValue(im)invokeMethod:withArguments:"
  },
  "title" : "invokeMethod(_:withArguments:)"
}
-->

# invokeMethod(_:withArguments:)

Calls the named JavaScript method on the value.

```
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 [`JSValue`](/documentation/JavaScriptCore/JSValue) objects or objects that can be converted to JavaScript values using the methods listed in the Creating JavaScript Values section in [`JSValue`](/documentation/JavaScriptCore/JSValue).

## Return Value

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

## Discussion

Calling this Objective-C method first uses the [`forProperty(_:)`](/documentation/JavaScriptCore/JSValue/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`](/documentation/JavaScriptCore/JSValue) instance.

---

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)