typeofで関数の有無を判定ができる。
See the Pen jsで関数の有無を判定 by takapen (@takapen) on CodePen.
// 確認のために関数を用意
function test() {
console.log('test実行');
}
// typeofで関数の時に返る値はfunctionなので、これで判定
if( typeof test === 'function') {
console.log('testがある場合');
test();//関数がある場合は実行
} else {
console.log('testがない場合');
}