Standard built-ins

SyntaxError()

Try the free JavaScript compiler

Indicates invalid syntax or failed parsing in relevant operations. Creating it does not throw automatically.

Formal Syntax & Structure

javascript syntaxjavascript
new SyntaxError([message], [options])

Parameters & Attributes

NameTypeDescription
messageStringDiagnostic text.
optionsObjectOptional cause property.

Return Value

SyntaxError

Error subtype instance.

Working Example

Example Snippetjavascript
console.log(new SyntaxError("example").name);
JavaScript Reference