<!--
{
  "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/init(object:in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:objc(cs)JSValue(cm)valueWithObject:inContext:"
  },
  "title" : "init(object:in:)"
}
-->

# init(object:in:)

Creates a JavaScript value by converting the specified native object.

```
init!(object value: Any!, in context: JSContext!)
```

## Parameters

`value`

The Objective-C or Swift object to be made available to JavaScript.

`context`

The JavaScript context in which to create the value.

## Return Value

A new JavaScript value representing the object.

## Discussion

Converting a native object creates a JavaScript object, including a constructor and prototype chain that reflects the object’s inheritance in the Objective-C or Swift type hierarchy. By default, properties and methods on the converted object are not exposed to JavaScript: to choose which properties and methods should be visible to JavaScript, see [`JSExport`](/documentation/JavaScriptCore/JSExport).

Creating a [`JSValue`](/documentation/JavaScriptCore/JSValue) instance that wraps a native object retains the underlying Objective-C or Swift object.

---

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)