How to check if an object has a function? (DoJo)

dojo, javascript

Solution

You can call it like this:

testObj.callableFunction && testObj.callableFunction();

or in details:

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

Problem

``` var testObj = this.getView(); ``` How can I check with DoJo (or just native JS) if testObj has `callableFunction` before I actually try to call `callableFunction()` and fail if it isn't there? I would prefer a native-DoJo solution as I need this to work on all browsers.

Original source