1

How can I manually throw a syntax error in a javascript function?

When a certain function in my program returns undefined, I want to throw a syntax error

3

1 Answer 1

3

It's not recommended (because you should create your own exception to handle some unusual situations in your code), but if you must you can do it like this:

throw SyntaxError("your message")
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.