<!--
{
  "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/JSObjectMakeFunctionWithCallback(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:@F@JSObjectMakeFunctionWithCallback"
  },
  "title" : "JSObjectMakeFunctionWithCallback(_:_:_:)"
}
-->

# JSObjectMakeFunctionWithCallback(_:_:_:)

Creates a JavaScript function with a specified callback as its implementation.

```
func JSObjectMakeFunctionWithCallback(_ ctx: JSContextRef!, _ name: JSStringRef!, _ callAsFunction: JSObjectCallAsFunctionCallback!) -> JSObjectRef!
```

## Parameters

`ctx`

The execution context to use.

`name`

A [`JSStringRef`](/documentation/JavaScriptCore/JSStringRef) that contains the function’s name. The system uses this when converting the function to a string. Pass `NULL` to create an anonymous function.

`callAsFunction`

The [`JSObjectCallAsFunctionCallback`](/documentation/JavaScriptCore/JSObjectCallAsFunctionCallback) to invoke when calling the function.

## Return Value

A [`JSObjectRef`](/documentation/JavaScriptCore/JSObjectRef) that is a function. The object’s prototype is the default function prototype.

## Discussion

---

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)