Given the following code, is there any way for me to detect if the closure returned by calling fn() contains a given method without having to execute fn itself?
// Example function which provides a closure with an 'execute' method.
var fn = function () {
return {
execute: function () {
}
};
};
// Test for the presense of an 'execute' method in the function's closure
if ("function" === typeof fn().execute) {
print("supplied function includes an execute method");
} else {
print("supplied function does not include an execute method");
}
Thanks!