script.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
// program to check if a variable is of function type function testVariable(variable) { if(Object.prototype.toString.call(variable) == '[object 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); |