Skip to main content
Version: 3.13.0


The SyntaxError constructor creates a new error object that represents an error when trying to interpret syntactically invalid code.


new SyntaxError()
new SyntaxError(message)
new SyntaxError(message, options)
new SyntaxError(message, fileName)
new SyntaxError(message, fileName, lineNumber)

SyntaxError(message, options)
SyntaxError(message, fileName)
SyntaxError(message, fileName, lineNumber)

Note: SyntaxError() can be called with or without new. Both create a new SyntaxError instance.


  • message optional
    • : Human-readable description of the error
  • options optional
    • : An object that has the following properties:
      • cause optional
        • : A property indicating the specific cause of the error. When catching and re-throwing an error with a more-specific or useful error message, this property can be used to pass the original error.