摘要: function getDate() { var time = new Date() var year = time.getFullYear() var month = time.getMonth() + 1 //月 var dates = time.getDate() //日 var arr = 阅读全文
posted @ 2022-05-08 17:10 健生 阅读(102) 评论(0) 推荐(0)
摘要: 得到两个数之间的随机整数包括两个数在内 function getRandomIntInclusive(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - m 阅读全文
posted @ 2022-05-07 19:56 健生 阅读(43) 评论(0) 推荐(0)
摘要: Date.parse("2015-08-24") // 获取1970年到设定时间的毫秒数 new Date().getTime() +new Date(); 两个指定的日期相差多少天 var date1=new Date(2010,10,3); var date2=new Date(2017,9,2 阅读全文
posted @ 2022-05-07 16:14 健生 阅读(38) 评论(0) 推荐(0)
摘要: 通过时间日期对象,可以将其中的年月日时分秒进行设置,改变时间日期对象的时间。 date.setFullYear(年份); // 设置时间日期对象中的年份 date.setMonth(当前月份-1); // 设置时间日期对象中的月份 - 这里的月份是通过0~11来描述1~12月的 date.setDa 阅读全文
posted @ 2022-05-07 16:13 健生 阅读(903) 评论(0) 推荐(0)
摘要: date.toLocalString();//本地风格的日期格式 date.toLocaleDateString(); // 获取日期 date.toLocaleTimeString(); // 获取时间 阅读全文
posted @ 2022-05-07 16:13 健生 阅读(20) 评论(0) 推荐(0)
摘要: 通过时间日期对象可以获取到具体的年月日时分秒,甚至毫秒和时间戳。 date.getFullYear(); // 获取到完整的时间日期对象中的年份 date.getMonth(); // 获取到时间日期对象中的月份 - 这里的月份是通过0~11来描述1~12月的 date.getDate(); // 阅读全文
posted @ 2022-05-07 16:12 健生 阅读(141) 评论(0) 推荐(0)
摘要: 圆周率 Math.PI // 3.1415926535 生成随机数 Math.random() //生成的是0~1之间的随机小数,通常在实际项目中需要获取到一个范围内的随机整数,利用这个随机小数封装一个获取范围内的随机整数的函数: function getRandom(a,b){ var max = 阅读全文
posted @ 2022-05-07 16:11 健生 阅读(160) 评论(0) 推荐(0)
摘要: //1,把旧数组里不重复的元素选取出来放到新数组中,重复的元素只保留一个,放到新数组中去重//2,遍历旧数组,然后拿旧数组的元素去查询新数组,如果该元素在新数组里没有出现过我们就添加,否则不添加//3.利用新数组.indenxOf(数组元素)如果返回是-1就说明新数组没有改元素function un 阅读全文
posted @ 2022-05-06 21:18 健生 阅读(82) 评论(0) 推荐(0)
摘要: charCodeAt - 根据指定下标获取对应的字符的阿斯克码 var str = 'abcdef'; // 获取下标为3的字符的阿斯克码 var res = str.charCodeAt(0); // 参数为指定的下标 console.log(res); // 97 String.fromChar 阅读全文
posted @ 2022-05-06 20:23 健生 阅读(38) 评论(0) 推荐(0)
摘要: 123 var arr = [1, 2, 3, 4, 5, 3, 6, 7, 3, 2]; for (var b = 0; b < arr.length - 1; b++) { for (var a = b + 1; a < arr.length; a++) { if (arr[b] arr[a]) 阅读全文
posted @ 2022-05-06 10:15 健生 阅读(12) 评论(0) 推荐(0)