I stumbled on this piece of code:
Function isolation (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", "(" + + + + ") (window)") (window)}'; Head.insertBefore (script, head.firstChild); Head.removeChild (script); ISO = win [name]; } ISO? ISO (FN): new function ("window", "(" + + ") (window)") (win); }
Is not it self-similar to the spiritual function? Is there any benefit to use it?
Thank you.
Is not it similar to the self-encoding function?
This is not equivalent to the expression of an immediate-applied function. But it is still equal to
different functions (win, FN) {FN (win); }
Because it wires fn
and re-eval it, destroys all the closing in the process.
Does anyone benefit from using it?
Yes, it allows you to move the function to a different global radius if you have multiple browsing references (for example, iframes, tabs, etc.), among them Each will have its own global field and global object. By inserting that script with the content
function __lord_isolate (f) {new function ("window", "(" + + + ") (window)") (window); }
They are creating a iso
function which is given in f
given code
Of course, this hack does not work more (and does not work everywhere) and is not a good practice, but there may be occasions where it is necessary.
No comments:
Post a Comment