<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "JavaScriptCore",
  "identifier" : "/documentation/JavaScriptCore/JSValue/context",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:objc(cs)JSValue(py)context"
  },
  "title" : "context"
}
-->

# context

The JavaScript context hosting this value.

```
var context: JSContext! { get }
```

## Discussion

A value maintains a strong reference to its enclosing JavaScript environment (a [`JSContext`](/documentation/JavaScriptCore/JSContext) object). As such, you should not store JavaScript values inside objects that are owned by the same [`JSContext`](/documentation/JavaScriptCore/JSContext) object, as this action creates a retain cycle. To properly manage memory when storing [`JSValue`](/documentation/JavaScriptCore/JSValue) instances, use the [`JSManagedValue`](/documentation/JavaScriptCore/JSManagedValue) class.

You can pass a value to other JavaScript contexts with the same virtual machine, but not to contexts with other virtual machines. Use the [`virtualMachine`](/documentation/JavaScriptCore/JSContext/virtualMachine) property of a value’s context to determine which other contexts can use the value.

---

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)