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