JavaScript ?? ??
JavaScript Math ??
Math ??? JavaScript?? ???? ?? ??? ???? ? ?????.
String ? Date ??? ?? Math ??? ??? ???? ??? ??? Math()? ???? Math ??? ?? ??? ??? Math ??? ?? ??? ? ????. ????? Math ??? ???? ?? ?????? Math.function? ?? ?? ??? ? ????.
Math ?? ??
JavaScript? ????? ???? ?? ?? ?? ???? Math ??? 8?? ??? ?????.
?? e, ?? ?? Math? ?????. LN2 2? ?? ??(?? 0.693? ??)
Math.LN10 10? ?? ??(?? 2.302? ??)
Math? ?? ??
Math ??? ? ??? ?? ??? ? ????.<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script type="text/javascript"> var pi = Math.PI; document.write(pi); </script> </head> <body> </body> </html>? ??? ???? ??? ?? ?????.
3.14159265 3589793
?? ???
Math ???? ??? ? ?? ?? ? ??? ??? ? ?? ?? ??(???)? ????.
?? ???? Math ??? round ???? ???? ??? ??????.
document.write(Math.round(4.7));
5
?? ???? Math ??? random() ???? ???? ?? ?????. 0? 1 ??? ??? ?? ??:document.write(Math.random());
? ??? ??? ??? ????.0.897235837765038
?? ????? Math ??? Floor() ???? random()? ???? 0? 11 ??? ??? ?????.
document.write(Math.floor(Math.random ()* 11));
? ??? ??? ??? ????.
2