javascript 随机取值 确定范围内的整数

Posted by bower on October 05, 2011
javascript

分享给你的朋友->bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

if(!Math.prototype.randomFromTo){
       Math.prototype.randomFromTo = function(from, to){
           return Math.floor(Math.random() * (to - from + 1) + from);
      };
}

Math.randomFromTo(100,1000) //950


分享到:人人网开心网腾讯微博新浪微博豆瓣分享腾讯空间百度搜藏腾讯书签

分享给你的朋友->bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word