1 2 3 4 5 6 7 8 9 10 11 | function isFunction( x ) { var getType = {}; // (x || false) guarantees returning of boolean type return ( x || false ) && [ '[object Function]', '[object GeneratorFunction]' ].indexOf( getType.toString.call( x ) ) >= 0; } module.exports = isFunction; |