If you call a function repeatedly, how do you make it execute in order?

<script>
  test()
  test()
  test()
  function test(){
    setTimeout(function () {
      console.log("test")
    },2000)
  }``
</script>

print at the same time after 2000 milliseconds, how can I print every 2000 milliseconds

Oct.23,2021

(function($loop, $timeout){
    function test(){
       console.log('test ['+$loop+']');
       
       if(--$loop > 0)
           setTimeout(test, $timeout);
    }
    
    setTimeout(test, $timeout)
})(3, 2000);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3eb46-409c0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3eb46-409c0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?