---
title: JSContext
framework: javascriptcore
role: symbol
role_heading: Class
path: javascriptcore/jscontext
---

# JSContext

A JavaScript execution environment.

## Declaration

```swift
class JSContext
```

## Overview

Overview You create and use JavaScript contexts to evaluate JavaScript scripts from Objective-C or Swift code; to access values that JavaScript defines or calculates; and to make native objects, methods, or functions accessible to JavaScript.

## Topics

### Creating JavaScript contexts

- [init()](javascriptcore/jscontext/init().md)
- [init(virtualMachine:)](javascriptcore/jscontext/init(virtualmachine:).md)

### Making JavaScript context inspectable

- [isInspectable](javascriptcore/jscontext/isinspectable.md)

### Evaluating scripts

- [evaluateScript(_:)](javascriptcore/jscontext/evaluatescript(_:).md)
- [evaluateScript(_:withSourceURL:)](javascriptcore/jscontext/evaluatescript(_:withsourceurl:).md)

### Inspecting callback state in a running context

- [current()](javascriptcore/jscontext/current().md)
- [currentCallee()](javascriptcore/jscontext/currentcallee().md)
- [currentThis()](javascriptcore/jscontext/currentthis().md)
- [currentArguments()](javascriptcore/jscontext/currentarguments().md)

### Working with JavaScript global state

- [globalObject](javascriptcore/jscontext/globalobject.md)
- [exception](javascriptcore/jscontext/exception.md)
- [exceptionHandler](javascriptcore/jscontext/exceptionhandler.md)
- [virtualMachine](javascriptcore/jscontext/virtualmachine.md)
- [name](javascriptcore/jscontext/name.md)

### Accessing JavaScript global state with subscripts

- [objectForKeyedSubscript(_:)](javascriptcore/jscontext/objectforkeyedsubscript(_:).md)
- [setObject(_:forKeyedSubscript:)](javascriptcore/jscontext/setobject(_:forkeyedsubscript:).md)

### Working with the C JavaScriptCore API

- [jsGlobalContextRef](javascriptcore/jscontext/jsglobalcontextref.md)
- [init(JSGlobalContextRef:)](javascriptcore/jscontext/init(jsglobalcontextref:)-9m51.md)

### Initializers

- [init(jsGlobalContextRef:)](javascriptcore/jscontext/init(jsglobalcontextref:)-1hstm.md)

### Default Implementations

- [JSContext Implementations](javascriptcore/jscontext/jscontext-implementations.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Execution Environment

- [JSVirtualMachine](javascriptcore/jsvirtualmachine.md)
