<!--
{
  "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/JSObjectCallAsConstructorCallback",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:@T@JSObjectCallAsConstructorCallback"
  },
  "title" : "JSObjectCallAsConstructorCallback"
}
-->

# JSObjectCallAsConstructorCallback

The callback type for using an object as a constructor.

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

## Parameters

`ctx`

The execution context to use.

`constructor`

A [`JSObjectRef`](/documentation/JavaScriptCore/JSObjectRef) that is the constructor to call.

`argumentCount`

An integer count of the number of arguments in `arguments`.

`arguments`

A [`JSValueRef`](/documentation/JavaScriptCore/JSValueRef) array of the arguments to pass to the function.

`exception`

A pointer to a [`JSValueRef`](/documentation/JavaScriptCore/JSValueRef) to return an exception in, if any.

## Return Value

A [`JSObjectRef`](/documentation/JavaScriptCore/JSObjectRef) that is the constructor’s return value.

## Discussion

If you name your function `CallAsConstructor`, you declare it like this:

```c
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.

---

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)