Skip to content

Instantly share code, notes, and snippets.

@emjayess
Created August 27, 2011 15:44
Show Gist options
  • Save emjayess/1175521 to your computer and use it in GitHub Desktop.
Save emjayess/1175521 to your computer and use it in GitHub Desktop.
advice: existence and type check for function arguments
function gimmeh_funcs(myfunc, callback) {
if (myfunc && typeof myfunc === 'function') {
/* myfunc is safe to use */
}
if (callback && typeof callback === "function") {
/* callback is safe to use */
}
}
@emjayess
Copy link
Author

see also add'l typeof caveats and a useful toType() implementation:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment