代碼:
復制代碼 代碼如下:
// 友善提醒:為了你的手指安全,請在Chrome下運行
'alert("hello")'.replace(/.+/, eval);
'alert("hello")'.replace(/.+/, function(m){new Function(m)();});
var i = 0; eval(new Array(101).join('alert(++i);'));
var i = 0; new Function(new Array(101).join('alert(++i);'))();
解釋:
1、string.replace(regexp, replacement): replacement可以是function. In this case, the function is invoked for each match, and the string it returns is used as the replacement text.
2、new Function(argument_names..., body): 注意參數中的body. 這樣,用new Function('body')()
, 也可以像eval一樣動態執行代碼。
3、array.join(separator): 這個最簡單,不多說。在這里,巧妙的用來解決了一個無聊問題:寫段代碼,運行后打印出從1到100的整數,不允許使用循環、跳轉和遞歸。
這些代碼可以干什么?可以肯定的是可以干很多猥瑣的事。具體是啥呢,自己想
主站蜘蛛池模板:
临夏市|
定南县|
佛教|
兴山县|
全椒县|
汕尾市|
南和县|
亚东县|
温州市|
舒兰市|
深圳市|
交城县|
天台县|
乾安县|
伊金霍洛旗|
迁安市|
金秀|
甘孜县|
喜德县|
黎城县|
博罗县|
静安区|
修文县|
二手房|
铜陵市|
西和县|
桓仁|
荣昌县|
博客|
疏附县|
武邑县|
长海县|
松原市|
红原县|
鄂尔多斯市|
育儿|
交口县|
玉山县|
保靖县|
前郭尔|
容城县|