- assigning a function to a name globally
- f(function(){ /* code */ }, "foo");
- foo(); // this call should now work!
- function f(g, n) {
- this[n] = g;
- }
- function f(g, n) {
- (function() { return this; })()[n] = g;
- }
- var addGlobalFunction = (function(global) {
- return function (fn, name) {
- global[name] = fn;
- };
- })(this);