I stumbled upon this piece of code:
function isolate(win, fn) {
var name = '__lord_isolate';
var iso = win[name];
if (!iso) {
var doc = win.document;
var head = document.head;
var script = doc.createElement('script');
script.type = 'text/javascript';
script.text = 'function ' + name + '(f){new Function("window","("+f+")(window)")(window)}';
head.insertBefore(script, head.firstChild);
head.removeChild(script);
iso = win[name];
}
iso ? iso(fn) : new Function("window", "(" + fn + ")(window)")(win);
}
is this not the same as self invoking function? Are there any benefits to using this?
Thanks.