How to check if a variable is of function type in JavaScript

1 Answer

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

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

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




/*
run:

false
true

*/

 



answered Jan 27, 2022 by avibootz

Related questions

1 answer 205 views
1 answer 299 views
1 answer 238 views
1 answer 231 views
1 answer 204 views
2 answers 254 views
...