Created
August 27, 2011 15:44
-
-
Save emjayess/1175521 to your computer and use it in GitHub Desktop.
advice: existence and type check for function arguments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 */ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see also add'l
typeof
caveats and a usefultoType()
implementation: