Possible Duplicate:
How can I check if a javascript variable is function type?
How i check if a variable is a function
for Array exist Array.isArray()
but Function.isFunction dos'nt exist
Possible Duplicate:
How can I check if a javascript variable is function type?
How i check if a variable is a function
for Array exist Array.isArray()
but Function.isFunction dos'nt exist
if (typeof variable === 'function') {
// do something
}
typeof class A {} === "function" is true.Underscore.js is a library that has a lot of useful helpers, like the one you're looking for.
_ = require('underscore');
var aFunction = function() { };
var notFunction = 'Not a function';
_.isFunction(aFunction); // true
_.isFunction(notFunction); // false
typeof obj == 'function' || false - github.com/jashkenas/underscore/blob/…