Created
August 2, 2011 21:46
-
-
Save DBJDBJ/1121314 to your computer and use it in GitHub Desktop.
DBJ isFunction()
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
| /* | |
| (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