详情链接:http://c.biancheng.net/view/8184.html

    1. 1) 获取 0~1.0 之间的随机数:
    2. Math.random();
    1. 2) 随机获取 0~10 之间的一个整数:
    2. Math.round(Math.random()*10);
    3. 首先使用 Math.random()*10 可得到 0~10.0 之间的一个随机数,
    4. 然后再使用 Math.round() 对 0~10.0 之间的随机数进行四舍五入,
    5. 最终就可得到 0~10 之间的一个随机整数。