Hàm random () của đối tượng Math trả về một số ngẫu nhiên dấu phẩy động trong khoảng từ 0,0 đến 1,0. Phạm vi là:0.0 =
Cú pháp
Cú pháp của nó như sau
Math.random();
Ví dụ
<html> <head> <title>JavaScript Example</title> </head> <body> <script type="text/javascript"> var result = Math.random(48, 2); document.write("Result "+result); </script> </body> </html>
Đầu ra
Result 0.16413337253303162