印象笔记迁移 global对象 1var box = '//dog学';2var a = encodeURI(box);3var b = encodeURIcomponent(box); //%2F%2Fdog%E5%AD%A64alert(a); // //dog%E5%AD%A65alert(b); // %2F%2Fdog%E5%AD%A66alert(decodeURI(a)); // //dog学7alert(decodeURIComponent(b)); // //dog学 1eval('var box = 100');2alert(box);3eval(alert(100)); //1004alert(eval(alert(100))); //100,undefined 第一个打印100,第二个打印eval的返回值5eval('function box(){return 123}');6alert(box()); //123 Math对象 1alert(Math.E); //2.7182818284590452alert(math.PI); //3.1415926535897933alert(Math.min(2,5,8,0)); //04alert(Math.max(2,5,8,0)); //85alert(Math.abs(-5)); //56alert(Math.sqrt(9)); //37 8alert(Math.ceil(25.1)); //269alert(Math.ceil(25.5)); //2610alert(Math.ceil(25.9)); //26,向上舍入11 12alert(Math.floor(25.1)); //2513alert(Math.floor(25.5)); //2514alert(Math.floor(25.9)); //25,向下舍入15 3 collapsed lines16alert(Math.round(25.1)); //2517alert(Math.round(25.5)); //2618alert(Math.round(25.9)); //26,标准的四舍五入 Math.random()方法:值= Math.floor(Math.random() *总数 + 第一个值) 1for (var i = 0; i < 10; i++) {2 document.write(Math.floor(Math.random() * 10 + 1));3 document.write('<br />');4} //1-10之间5 6for (var i = 0; i < 10; i++) {7 document.write(Math.floor(Math.random() * 6 + 5));8 document.write('<br />');9} //5-10之间10 11function select(start, end) {12 var total = end - start + 1;13 return Math.floor(Math.random() * total + start);14}15 4 collapsed lines16for (var i = 0; i < 10; i++) {17 document.write(select(5, 10));18 document.write('<br />');19} //5-10之间