dynamic - Regarding JavaScript function unorthodoxy -


I've been programming for the web for some time, but just recently have discovered some new complications Uses and weird (either I see them) with those things you can do however, they are just syntactically beautiful things at this point. I was hoping someone found out that in these new investigative aspects How some can prove to be useful For example, for the first time I visited this, I was convinced that this would not work:

  & lt; Script & gt; Function x (q) {q (x); } X (function (A) {warning (A);}); & Lt; / Script & gt;  

But did it! Either way, creating a named function that gets a different, benami function as its only parameter, and then the passed function is passed to itself, because it passed as a parameter It goes, it works fine. It blown my mind positively and I am almost certain that there is a lot of practicality for this, but I can not keep it quite yet.

Ah, and one more thing I find: To store functions, a globally scoppy variable, in a subsequent execution to modify the variable's eval () function of that variable , Which dynamically changes the internal functioning of the function. One example:

  & lt; Script & gt; Var f = function (warnings ('old text'); } Eval ('f =' + f.toString (). Change ('old text', 'new text')); F (); & Lt; / Script & gt;  

Of course, this code gives the string "new text" string; When I saw that my brain was blown up again, but I was immediately worried about the ability to make anything unbelievable.

So ... my burning question for stack overflow: It appears that abstract coding principles can be used in any positive way?

Just google and you'll find hundreds of uses and examples. / P>


Comments