In its current state, JavaScript does not support the exact functions you need. The post in the commentary gives detailed information about what can and cannot be done. However, if you are ready to refuse the use of "." invoke method, heres a sample code that is close to what you want:
var o = { show: function(m) { alert(m); }, invoke: function(methname, args) { try { this[methname](args); } catch(e) { alert("Method '" + methname + "' does not exist"); } } } o.invoke("show", "hello"); o.invoke("sho", "hello");
Output:
Hello
The 'sho' method does not exist
source share