---
title: "JSCheckScriptSyntax(_:_:_:_:_:)"
framework: JavaScriptCore
role: symbol
role_heading: Function
platforms: [iOS 16.0+, iPadOS 16.0+, Mac Catalyst 13.0+, macOS 10.5+, tvOS 9.0+, visionOS 1.0+]
path: "javascriptcore/jscheckscriptsyntax(_:_:_:_:_:)"
---

# JSCheckScriptSyntax(_:_:_:_:_:)

Checks for syntax errors in a string of JavaScript.

## Declaration

```swift
func JSCheckScriptSyntax(_ ctx: JSContextRef!, _ script: JSStringRef!, _ sourceURL: JSStringRef!, _ startingLineNumber: Int32, _ exception: UnsafeMutablePointer<JSValueRef?>!) -> Bool
```

## Parameters

- `ctx`: The execution context to use.
- `script`: A doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSStringRef that contains the script to check for syntax errors.
- `sourceURL`: A doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSStringRef that contains a URL for the script’s source file. The system only uses this when reporting exceptions. Pass NULL to omit source file information in exceptions.
- `startingLineNumber`: An integer value that specifies the script’s starting line number in the file at sourceURL. The system only uses this when reporting exceptions.
- `exception`: A pointer to a doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSValueRef to store a syntax error exception in, if any. Pass NULL to ignore any syntax error exception.

## Return Value

Return Value true if the script is syntactically correct; otherwise, false.

## See Also

### Script Evaluation

- [JSEvaluateScript(_:_:_:_:_:_:)](javascriptcore/jsevaluatescript(_:_:_:_:_:_:).md)
- [JSGarbageCollect(_:)](javascriptcore/jsgarbagecollect(_:).md)
