javascript Math.random()随机数函数
作者:bea
random函数语法 Math.random(); random函数参数 无参数 random函数返回值 返回0和1之间的伪随机数,可能为0,但总是小于1,[0,1) random函数示例 document.write(Math.random()); 返回随机数 document.write(Math.random()*(20-10)+10); 返回10-20的随机数 document.write(Math.random()*(n-m)+m); 返回指定范围的随机数(m-n之
random函数语法
Math.random();
random函数参数
无参数
random函数返回值
返回0和1之间的伪随机数,可能为0,但总是小于1,[0,1)
random函数示例
document.write(Math.random());
返回随机数
document.write(Math.random()*(20-10)+10);
返回10-20的随机数
document.write(Math.random()*(n-m)+m);
返回指定范围的随机数(m-n之间)的公式
有用 |
无用
Math.random();
random函数参数
无参数
random函数返回值
返回0和1之间的伪随机数,可能为0,但总是小于1,[0,1)
random函数示例
document.write(Math.random());
返回随机数
document.write(Math.random()*(20-10)+10);
返回10-20的随机数
document.write(Math.random()*(n-m)+m);
返回指定范围的随机数(m-n之间)的公式
猜你喜欢
您可能感兴趣的文章:
- javascript showModalDialog传值与FireFox的window.open 父子窗口传值示例
- CSS+Js遮罩效果的TAB及焦点图片切换(推荐)
- 让Firefox支持event对象实现代码
- extjs DataReader、JsonReader、XmlReader的构造方法
- fileupload控件 文件类型客户端验证实现代码
- JavaScript 变量基础知识
- 表格 隔行换色升级版
- csdn 论坛技术区平均给分功能
- js 操作table之 移动TR位置 兼容FF 跟 IE
- 按键盘方向键翻页跳转的javascript代码(支持ie,firefox)
- 在js中单选框和复选框获取值的方式
- javascript 常见的闭包问题的解决办法
- 模仿JQuery sortable效果 代码有错但值得看看
- javaScript parseInt字符转化为数字函数使用小结
- jQuery toggle()设置CSS样式
- javascript 打印内容方法小结
- 兼容多浏览器的iframe自适应高度(ie8 、谷歌浏览器4.0和 firefox3.5.3)
- JavaScript 自动分号插入(JavaScript synat:auto semicolon insertion)
- jQuery 加上最后自己的验证