throw 'Invalid input'; <- This will automatically create an instance of an Error object with the message βInvalid inputβ, but the error instance can also be created manually and passed around.
No, no, no! That will throw a useless string, not an Error. The string will have no helpful stack trace and may trigger a cascade of failures in error handlers expecting an Error object.
ALWAYS throw an error, NEVER throw a string or anything else.
Wrong info in section "Manually throwing errors":
No, no, no! That will throw a useless string, not an Error. The string will have no helpful stack trace and may trigger a cascade of failures in error handlers expecting an Error object.
ALWAYS throw an error, NEVER throw a string or anything else.
References: