exist function in js code example
Example: javascript check if function exists
if (typeof sourceObj.someMethod === "function") {
// you are safe using the method
sourceObj.someMethod();
}
if (typeof sourceObj.someMethod === "function") {
// you are safe using the method
sourceObj.someMethod();
}