The SyntaxError
object represents an error when trying to interpret syntactically invalid code. It is thrown when the JavaScript engine encounters tokens or token order that does not conform to the syntax of the language when parsing code.
SyntaxError
is a serializable object, so it can be cloned with structuredClone()
or copied between Workers using postMessage()
.
SyntaxError
is a subclass of Error
.