Imagine a scenario where I have a function that specifically accepts non-negative numbers, but is given a negative argument.
If this were in Python, I would raise a ValueError
. In Java, an IllegalArgumentException
would be thrown. Is there a built-in exception that should be used in JavaScript for this situation, or is it best to simply return undefined
?