Suppose I have any variable, which is defined as follows:
var a = function() {/* Statements */};
I want a function which checks if the type of the variable is function-like. i.e. :
function foo(v) {if (v is function type?) {/* do something */}};
foo(a);
How can I check if the variable 'a' is of type function in the way defined above?
Since node v0.11 you can use the standard util function :
An other simply way:
I think you can just define a flag on the Function prototype and check if the instance you want to test inherited that
define a flag:
and then check if it exist
The downside is that another prototype can define the same flag and then it's worthless, but if you have full control over the included modules it is the easiest way
you should use
typeOf
operator in js.jQuery (deprecated since version 3.3) Reference
AngularJS Reference
Lodash Reference
Underscore Reference
Node.js deprecated since v4.0.0 Reference