JavaScript Program to Check If a Variable is of Function Type
// program to check if a variable is of function type
function testVariable(variable) {
if(variable instanceof Function) {
console.log('The variable is of function type');
}
else {
console.log('The variable is not of function type');
}
}
const count = true;
const x = function() {
console.log('hello')
};
testVariable(count);
testVariable(x);
Output
The variable is not of function type The variable is of function type
