Instantly share code, notes, and snippets.
The advantage of Export or globalize is that you could implement some sort of fancy AMD system using that same API or something maybe I guess sortof.
Note that Export won't work globally because we'd have to define it in every file. The idea of applyToGlobal is to not have to fetch the global object mor than once.
Also, I liked how you replaced 1 with 7 in the indirect eval call, heh.
I think we can handle 53 characters at the top of each file ;)
yeah, but potentially use eval in every single module? I dislike.
What's the alternative?
You have to get Export or applyGlobal into the universe somehow.
the upside of applyToGlobal is that you only have to get the context once and reuse that on every function call.
Like I had mentioned on another comment.. is this possible as well?
var global = this || (1, eval)('this');
global.global = global;
// or I guess directly: