They essentially try to do the same thing, but the
setInterval approach will be more accurate than the
setTimeout approach, since
setTimeout waits 1000ms, runs the function and then sets another timeout. So the wait period is actually a bit more than 1000ms (or a lot more if your function takes a long time to execute).
Altough one might think that
setInterval will execute exactly every 1000ms, it is important to note that
In this Fiddle, you can clearly see that the timeout will fall behind, while the interval is almost all the time at 1 call/second (which the script is trying to do). If you change the speed variable at the top to something small like 20 (meaning it will try to run 50 times per second), the interval will never quite reach an average of 50 iterations per second.
The delay is almost always negligible, but if you're programming something really precise, you should go for a self-adjusting timer (which essentially is a timeout-based timer that constantly adjusts itself for the delay it's created)