!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8">
  <title></title>
 </head>
 <body>
 <script type="text/javascript">
  var marry =new Array(0,01,02,03,04,05,06,07,08,09,10)
  var num =Math.random()*10;
  document.write(marry[Math.round(num)]);
 </script>
 </body>
</html>
js不能直接输出数字前面的0,例如【document.write(000000001);】,输出结果为1
数组中的值存放的是字符串(加双引号),可以实现你想要的效果:
var marry =new Array(0,"01","02","03","04","05","06","07","08","09",10); var num =Math.random()*10; document.write(marry[Math.round(num)]);