<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
function getTime() {
return new Date().getTime()
}
function test(){
let perTime = getTime();
let timer = null;
let i=0;
timer = requestAnimationFrame(run);
function run(){
let nowTime = getTime();
if(nowTime - perTime >5000){
perTime = getTime();
console.log(i++)
}
timer = requestAnimationFrame(run);
}
}
test();
</script>
</body>
</html>