<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "JavaScriptCore",
  "identifier" : "/documentation/JavaScriptCore/JSGlobalContextCreate(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:@F@JSGlobalContextCreate"
  },
  "title" : "JSGlobalContextCreate(_:)"
}
-->

# JSGlobalContextCreate(_:)

Creates a global JavaScript execution context.

```
func JSGlobalContextCreate(_ globalObjectClass: JSClassRef!) -> JSGlobalContextRef!
```

## Parameters

`globalObjectClass`

The class to use when creating the global object. Pass `NULL` to use the default object class.

## Return Value

A [`JSGlobalContextRef`](/documentation/JavaScriptCore/JSGlobalContextRef) with a global object of class `globalObjectClass`.

## Discussion

[`JSGlobalContextCreate(_:)`](/documentation/JavaScriptCore/JSGlobalContextCreate(_:)) allocates a global object and populates it with all the built-in JavaScript objects, such as `Object`, `Function`, `String`, and `Array`.

In WebKit 4 and later, the system creates the context in a unique context group. Therefore, scripts may execute in it concurrently with scripts executing in other contexts. However, you may not use values from the context in other contexts.

---

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)