×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: petecocoon
Added: Jan 27, 2012 11:31 AM
Views: 37
Syntax:
getNameSpacedFunction("Math.abs")
Return:
Math.abs function
  1. getNameSpacedFunction =  function(functionName){
  2.         var namespaces = functionName.split(".");
  3.         var func = namespaces.pop();
  4.         var context = window;
  5.         for(var i = 0; i < namespaces.length; i++) {
  6.                 context = context[namespaces[i]];
  7.         }
  8.         return context[func];
  9. }