Skip to content

Instantly share code, notes, and snippets.

@DBJDBJ
Created August 2, 2011 21:46
Show Gist options
  • Select an option

  • Save DBJDBJ/1121314 to your computer and use it in GitHub Desktop.

Select an option

Save DBJDBJ/1121314 to your computer and use it in GitHub Desktop.
DBJ isFunction()
/*
(c) 2009 - 2011 by dbj.org
*/
var isFunction = (function() {
var rx = /^\s*\bfunction\b/;
return function(f) {
return rx.test(f);
}
}());
/*
Anti Jokers version, who think it is awesome
to abuse code with calls like this:
isFunction("function");
(c) 2009 - 2011 by dbj.org
*/
var isFunction4jokers = (function() {
var rx = /^\s*\bfunction\b/;
return function(f) {
return "function" === typeof f ? true : "object" === typeof f ?
rx.test(f) : false;
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment