Suppose I have any variable, which is defined as follows:
var a = function() {/* Statements */};
I want a function which checks if the type
Underscore.js uses a more elaborate but highly performant test:
_.isFunction = function(obj) {
return !!(obj && obj.constructor && obj.call && obj.apply);
};
See: http://jsperf.com/alternative-isfunction-implementations
EDIT: updated tests suggest that typeof might be faster, see http://jsperf.com/alternative-isfunction-implementations/4