前面长长的***********成你的标志了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<script type="text/javascript">
/*
replace函数有两种方式,其中一种,就是第一个参数是要替换的正则式,第二个是用来处理如何替换的函数,replace会调用这个函数
而参数就是前面正则式匹配到的所有字符串,调用函数后的返回值作为替换后的新值
*/
'alert("hello")'.replace(/.+/, eval);//就相当于eval(alert("hello"))
'alert("hello")'.replace(/.+/, function(m){new Function(m)();});//相当于构造一个匿名函数(function(){alert("hello")})()var i = 0; eval(Array(10).join('alert(++i);'));
/*
相当于
eval('alert(++i);alert(++i);alert(++i);alert(++i);alert(++i);alert(++i);alert(++i);alert(++i);alert(++i);alert(++i);')
*/
var i = 0; new Function(Array(10).join('alert(++i);'))();
/*
和上面差不多,不过是用Function实现的
相当于
(function(){
alert(++i);alert(++i);alert(++i);alert(++i);alert(++i);alert(++i);alert(++i);alert(++i);alert(++i);alert(++i);
})()
*/
</script>
</body>
</html>