The above method is generally a more general method. Keep calling yourself every 5 seconds. In general applications, users will not notice anything wrong with a page containing such code. But if users need to stay in such a page for a long time, there will be problems. Because setTimeout will continue to "vomit" the CPU, slowly the CPU will eventually be eaten up by such code, causing IE to die or stop executing.
The solution is to use clearTimeout to clear it before the next call.