Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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);
}
 
PREVIOUS NEXT
Tagged: #function #javascript
ADD COMMENT
Topic
Name
5+4 =