setInterval is actually evil, if the code inside setInterval takes longer than the time you set, it will create another process before the function finishes ruining everything. So choosing setTimeout is actually better.
To make function loops in setTimeout , use the following syntax:
function function1() { console.log({} + [] + " = {} + []");
source share