How to check if a variable is of function type in Node.js

1 Answer

0 votes
function isfunctiontype(variable) {
    return variable instanceof Function
}

const b = true;
console.log(isfunctiontype(b));

const a = function() {
    return 738
};
console.log(isfunctiontype(a));




/*
run:

false
true

*/

 



answered Jan 27, 2022 by avibootz

Related questions

1 answer 121 views
121 views asked Feb 4, 2022 by avibootz
1 answer 142 views
1 answer 114 views
2 answers 146 views
2 answers 191 views
1 answer 111 views
1 answer 165 views
...