check function is available javascript code example
Example 1: javascript check if function exists
if (typeof sourceObj.someMethod === "function") {
// you are safe using the method
sourceObj.someMethod();
}
Example 2: js check if function exists
if (typeof yourFunctionName == 'function') {
yourFunctionName();
}