<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.5.0 -",
    "swift: -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "JavaScriptCore",
  "identifier" : "/documentation/JavaScriptCore/JSValue/init(rect:inContext:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:objc(cs)JSValue(cm)valueWithRect:inContext:::SYNTHESIZED::c:objc(cs)JSValue"
  },
  "title" : "init(rect:inContext:)"
}
-->

# init(rect:inContext:)

Creates a JavaScript representation of the specified rectangle.

```
init!(rect: CGRect, inContext context: JSContext!)
```

## Parameters

`rect`

A CoreGraphics rectangle structure.

`context`

The JavaScript context in which to create the value.

## Return Value

A JavaScript object representing the specified rectangle.

## Discussion

Converting a rectangle creates a JavaScript object value with fields named `x`, `y`, `width`, and `height`.

---

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)