Are there any significant reasons for using
typeof variable === \'function\'
versus
!!variable.call
for d
The safest way is to check the internal [[Class]] property by setting the object as the thisArg argument of the .call() method when calling Object.prototype.toString.
Object.prototype.toString.call( myVariable ) === '[object Function]';
Of course you could easily make a function out of it:
function checkClass( obj ) {
return Object.prototype.toString.call( obj ).slice( 8, -1).toLowerCase();
}
checkClass( myVariable ) === 'function';
This is very simple, and there could be some improvements, but you get the idea.