JS内置对象Math 和Date 的详解

时间:2023-10-18来源:互联网作者:挽青丝

JS内置对象 Math 和 Date 的详解

var random=Math.random();console.log(random);//每一次刷新都不一样,小于1的随机数:0.458541256325412//生成x~x之间的随机整数function getRandom(n,m){    var choise=m-n+1;//随机整数的个数    return Math.floor(Math.random()*choise+n);}var random1=getRandom(2,6);console.log(random1);//5 3 2...

二、date对象

1.创建日期对象的方法语法:new Date();功能:创建一个日期时间对象返回值:不传参的情况下,返回当前的日期时间对象。

相关文章
图文推荐
猜你喜欢