check if function exists javascript
JavaScript
if (typeof sourceObj.someMethod === "function") {
// you are safe using the method
sourceObj.someMethod();
}//check if sayHello() function exists
if (typeof sayHello === "function") {
// This function exists
}
if (typeof payment === "function")
{
// Do something
}