日期对象
数组对象
定时器关键字: setInterval+函数自定义名称
关闭定时器:setTimeout+函数自定义名称
可以用订时器随机数或随机选人等
如:用定时器的原理打出实时的时间
<body>
<span id="time">
</span>
<script type="text/javascript">
setInterval(function(){
var time = new Date()
console.log(time)
var Year = time.getFullYear()
var month = time.getMonth()+1
var date = time.getDate()
var hours = time.getHours()
var minutes = time.getMinutes()
var seconds = time.getSeconds()
month = month > 9 ? month : "0" + month
date = date > 9 ? date : "0" + date
hours = hours > 9 ? hours : "0" + hours
minutes = minutes > 9 ? minutes : "0" + minutes
seconds = seconds > 9 ? seconds : "0" + seconds
var result = Year + "年" + month + "月" + date + "日" + hours + ":" + minutes + ":" + seconds
document.getElementById("time").innerHTML=result
},1000)
setTimeout(function(){
console.log("aa")
},2000)
</script>
</body>