does this exists in a function javascript code example
Example 1: javascript check if function exists
//check if sayHello() function exists
if (typeof sayHello === "function") {
// This function exists
}
Example 2: javascript check if function exists
if (typeof sourceObj.someMethod === "function") {
// you are safe using the method
sourceObj.someMethod();
}