---
title: JSObjectCallAsConstructorCallback
framework: javascriptcore
role: symbol
role_heading: Type Alias
path: javascriptcore/jsobjectcallasconstructorcallback
---

# JSObjectCallAsConstructorCallback

The callback type for using an object as a constructor.

## Declaration

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

## Parameters

- `ctx`: The execution context to use.
- `constructor`: A doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSObjectRef that is the constructor to call.
- `argumentCount`: An integer count of the number of arguments in arguments.
- `arguments`: A doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSValueRef 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 JSObjectRef that is the constructor’s return value.

## Discussion

Discussion If you name your function CallAsConstructor, you declare it like this: JSObjectRef CallAsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); If the JavaScript expression new myConstructor() invokes your callback, it sets constructor to myConstructor. If this callback is NULL, using your object as a constructor in a new expression 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)
