check if function exists on object javascript 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();
}