When coding a library in JavaScript, what is the most standard (friendliest?) way to handle invalid input to a function? My gut tells me that returning undefined is perfectl
I think undefined
is fine but keep in mind that:
JavaScript does not have a void type, so every function must return a value. The default value is undefined, except for constructors, where the default return value is this.
So you don't need to explicitly returns undefined. It will be by default.
see http://javascript.crockford.com/survey.html