They both essentially try to do the same thing, but the setInterval approach is more accurate than the setTimeout function, since the setTimeout function waits 1000ms, it runs the function and sets another timeout this would make the waiting period more than 1000ms.
Though you might think that setInterval is going to execute exactly every 1000ms, it is important to note that setInterval will also delay as Javascript is not a multithreaded language, which means that if there are other parts of the script running then the interval will have to wait for that to finish.
If your programming something precise that does not need these delays, you should go for a self-adjusting timer.
Want to be a full stack developer? Check out the full stack developer course from Intellipaat.