javascript run every 5 seconds
snippet in javascript

javascript run every 5 seconds

user9220

const interval = setInterval(function() {
   // method to be executed;
 }, 5000);

clearInterval(interval); // thanks @Luca D'Amico