2013-02-19 16 views

答えて

78

あなたはこのようにそれを呼び出すことができます。

testObj.callableFunction && testObj.callableFunction(); 

や詳細には:

if (typeof testObj.callableFunction == 'function') { 
    testObj.callableFunction(); 
} 
+0

ありがとうございます!これは動作します:) – antonpug

+0

あなたは歓迎です:) – dfsq

+0

@ dfsqこれは=== 'function'ではありませんか? – Ethan

2

あなたは、プロパティが存在し、関数であることをテストする必要があります。

var returnFromCallable = typeof testObj.callableFunction === 'function' && 
    testObj.callableFunction(); 
4

道場を持っていますテストの実行に使用できる関数です。

require(["dojo/_base/lang"], function(lang){ 

    var testObj = this.getView(); 
    if(lang.isFunction(testObj.callableFunction)){ 
    testObj.callableFunction(); 
    } 

}); 
関連する問題