After following, you can keep track of his dynamic information in a timely manner
Courses in the relevant section:Based on JS(01)
<!doctype html> <html lang="en"> <head> <title>Document</title> </head> <body> <script> /*******************/ // 数值类型 var pi = 3.1415926; var str1 = Number.toString(pi); document.write(pi); document.write('<br>'); // 保留两位 var pi2 = pi.toFixed(2); document.write(pi2); document.write('<br>'); //返回指定位数 var pi3 = pi.toPrecision(6); document.write(pi3); document.write('<br>'); // 四舍五入 document.write(Math.round(4.7)); document.write('<br>'); // 随机数 document.write(Math.random()); document.write('<br>'); document.write(Math.floor(Math.random()*11)); document.write('<br>'); /*******************/ // 字符串的转义 var str4 = '3.61'; var num = Number(str4); var p = num + 0.090; document.write(p); document.write('<br>'); document.write('你好\r 测试'); /*******************/ // 布尔类型 // true var s= 1; var t = []; var u = {}; var d = null; var e = false; var n = undefined; </script> </body> </html>
2018-01-230个赞