I have gone through multiple approaches to check if a variable is a function but I can't figure out the advantages and disadvantages, which one to use and why.
Are there any edge cases where my comparison can fail in case of typeof
?
1) function isFunction(functionToCheck) {
return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]'; }
2) typeof functionToCheck === 'function'
3) functionToCheck.constructor === Function