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