---
title: JSObjectCallAsFunctionCallback
framework: javascriptcore
role: symbol
role_heading: Type Alias
path: javascriptcore/jsobjectcallasfunctioncallback
---

# JSObjectCallAsFunctionCallback

The callback type for calling an object as a function.

## Declaration

```swift
typealias JSObjectCallAsFunctionCallback = (JSContextRef?, JSObjectRef?, JSObjectRef?, Int, UnsafePointer<JSValueRef?>?, UnsafeMutablePointer<JSValueRef?>?) -> JSValueRef?
```

## Parameters

- `ctx`: The execution context to use.
- `function`: A doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSObjectRef that is the function to call.
- `thisObject`: A doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSObjectRef that is the this variable in the function’s scope.
- `argumentCount`: An integer count of the number of arguments in arguments.
- `arguments`: A JSValue array of the arguments to pass to the function.
- `exception`: A pointer to a doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSValueRef to return an exception in, if any.

## Return Value

Return Value A JSValueRef that is the function’s return value.

## Discussion

Discussion If you name your function CallAsFunction, you declare it like this: JSValueRef CallAsFunction(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); If the JavaScript expression myObject.myFunction() invokes your callback, it sets function to myFunction, and thisObject to myObject. If this callback is NULL, calling your object as a function throws an exception.

## See Also

### Managing Callbacks

- [initialize](javascriptcore/jsclassdefinition/initialize.md)
- [JSObjectInitializeCallback](javascriptcore/jsobjectinitializecallback.md)
- [finalize](javascriptcore/jsclassdefinition/finalize.md)
- [JSObjectFinalizeCallback](javascriptcore/jsobjectfinalizecallback.md)
- [hasProperty](javascriptcore/jsclassdefinition/hasproperty.md)
- [JSObjectHasPropertyCallback](javascriptcore/jsobjecthaspropertycallback.md)
- [getProperty](javascriptcore/jsclassdefinition/getproperty.md)
- [JSObjectGetPropertyCallback](javascriptcore/jsobjectgetpropertycallback.md)
- [setProperty](javascriptcore/jsclassdefinition/setproperty.md)
- [JSObjectSetPropertyCallback](javascriptcore/jsobjectsetpropertycallback.md)
- [deleteProperty](javascriptcore/jsclassdefinition/deleteproperty.md)
- [JSObjectDeletePropertyCallback](javascriptcore/jsobjectdeletepropertycallback.md)
- [getPropertyNames](javascriptcore/jsclassdefinition/getpropertynames.md)
- [JSObjectGetPropertyNamesCallback](javascriptcore/jsobjectgetpropertynamescallback.md)
- [callAsFunction](javascriptcore/jsclassdefinition/callasfunction.md)
