let mymath={
PI:3.14,
max:function () {
max=arguments[0];
for(let i=1;i<arguments.length;i++){
if(arguments[i]>max)
{
max=arguments[i];
}
}
return max;
},
let num =prompt("你来猜1~10的数字")
arguments:表示了函数执行时传入函数的所有参数
prompt:弹出输入框,让你输入东西
alert:弹出提示框(确定)
confirm:弹出确认框(确认,取消)
倒计时效果:
<script>
//倒计时效果
function countDown(time) {
let nowDate =+new Date();
let inputTime =+new Date(time);
let times=(inputTime-nowDate)/1000;
let d=parseInt(times/60/60/24);
d = d <10 ? "0"+d : d;
let h = parseInt(times /60 /60 %24);
h = h <10 ? "0" + h : h;
let f = parseInt(times /60 %60);
f = f <10 ? "0" + f : f;
let s = parseInt(times %60);
s = s < 10 ? "0" + s : s;
return d + "天" + h + "时" + f +"分" +s +"秒";
}
console.log(countDown("2020-5-10 20:00:00"));
</script>
+new Date() 显示距离1970.1.1 的毫秒数