5-11 请问还有哪里需要优化
来源:5-11 编程练习
jia_蛙
2019-10-11 15:26:55
<!DOCTYPE html>
<html>
<head>
<title>运算符</title>
</head>
<body>
<script type="text/javascript">
//定义字符串hello,imooc!
var str = "hello,imooc!"
//取出子串imooc并输出
console.log(str.substr(6,5));
//定义日期,值为2019-5-1
var date = new Date("2019-5-1");
//分别输出年月日的值
console.log("现在是北京时间:" + date.getFullYear() +
"年" + date.getMonth() +"月" +
date.getDate()+"日");
//求一组数20,41,15,8的最大值和最小值并输出
console.log("最小值:" + Math.min(20,41,15,8));
console.log("最大值:" + Math.max(20,41,15,8));
</script>
</body>
</html>1回答
同学你好,这里复制运行贴出代码;

getMonth()的返回值是 0(一月) 到 11(十二月) 之间的一个整数,所以这里我们要在得到的返回值上+1.
如果我的回答解决了你的疑惑,请采纳,祝学习愉快~
相似问题