Skip to content

Instantly share code, notes, and snippets.

@aMarCruz
Created May 4, 2015 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aMarCruz/50a7b8be65a7bdf535eb to your computer and use it in GitHub Desktop.
Save aMarCruz/50a7b8be65a7bdf535eb to your computer and use it in GitHub Desktop.
Returns true if argument is a function (CommonJS)
// Safe isFunction()
// Avoid a Chakra JIT bug in compatibility modes of IE 11.
var isFunction = function (expr) {
return typeof expr === 'function' || false;
};
if (isFunction(/./) || (Uint8Array && !isFunction(Uint8Array))) {
isFunction = (function (expr) {
var _toString = Object.prototype.toString;
return function (expr) {
return _toString.call(expr) === '[object Function]';
};
})();
}
module.exports = isFunction;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment