js获取任意区间内的随机数

版权声明:请尊重原创 https://blog.csdn.net/Ag_wenbi/article/details/84023349
var _={
        random:function(start,stop){
            return parseInt(Math.random()*(stop-start)+start);
        }
    }
console.log(_.random(-5,5));//得到-5~5之间的随机数

猜你喜欢

转载自blog.csdn.net/Ag_wenbi/article/details/84023349