Tutorial Check if Function Exists Before Calling
by Unknown in javascript , Tutorial 0
When using scripts that are shared between different areas of a site, there may be cases where a function is called that doesn't exist. It makes sense on one page (the dependency is there) but not another. The difference is too slight to warrant forking the file into different versions. Instead, you can just check if the function exists before calling it to avoid the error:
if (typeof yourFunctionName == 'function') {
yourFunctionName();
}