×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Jing Tai Piao
Added: Jan 14, 2014 4:02 AM
Views: 17
Tags: no tags
  1. function executeFunctionByName(functionName, context /*, args */) {
  2.   var args = Array.prototype.slice.call(arguments).splice(2);
  3.   var namespaces = functionName.split(".");
  4.   var func = namespaces.pop();
  5.   for(var i = 0; i < namespaces.length; i++) {
  6.     context = context[namespaces[i]];
  7.   }
  8.   return context[func].apply(this, args);
  9. }