Answers for "javascript is a function"

3

js is function

if(typeof test === "function") {
  console.log('test is a function');
}else {
  console.log('test is not a function');
}
Posted by: Guest on July-11-2021
2

is function javascript

// There are various ways to test if a variable is of function type
// typeof check
if(typeof test === "function"){
  // do something with function
  test()
}
// instanceof check
if(test instanceof Function){
  // do something with function
  test()
}
// call check
if(test?.call !== "undefined"){
   test.call({}, arg1, arg2);
}
Posted by: Guest on April-23-2022

Code answers related to "javascript is a function"

Code answers related to "Javascript"

Browse Popular Code Answers by Language