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.
@example
import{ SyntaxError }from'@w5s/error'; try{ thrownewSyntaxError("Hello"); }catch(e){ console.log(e instanceofSyntaxError);// true console.log(e.message);// "Hello" console.log(e.name);// "SyntaxError" console.log(e.stack);// Stack of the error }
Alias to native globalThis.SyntaxError
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.