Code:
Copy Code code as follows:
Friendly reminder: For your fingers to be safe, please run it under Chrome
' Alert (' Hello ') '. Replace (/.+/, eval);
' Alert (' Hello ') '. Replace (/.+/, function (m) {new function (m) ();});
var i = 0; Eval (new Array. Join (' alert (++i); ');
var i = 0; New Function (New Array (' Alert (++i); ') ();
Explain:
1, String.Replace (RegExp, replacement): Replacement can be a function. In this case, the function was invoked for each match, and the string it returns is used as the replacement text.
2, New Function (Argument_names ..., body): Note the body in the parameter. In this way, with the new Function (' body ') ()
, or you can execute code dynamically like an eval.
3, Array.join (separator): This is the simplest, not much to say. Here, cleverly used to solve a boring problem: write a piece of code, run print out from 1 to 100 of integers, do not allow the use of loops, jumps and recursion.
What can this code do? You can be sure that you can do a lot of wretched things. What exactly is it, I think.