Path: csiph.com!1.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: setInterval Date: Tue, 07 Feb 2017 21:54:29 +0100 Organization: PointedEars Software (PES) Lines: 30 Message-ID: <2548632.e9J7NaK4W3@PointedEars.de> References: <6cb902b0-8913-4b65-954d-5d9f0e60ee95@googlegroups.com> <4cbfae02-e217-436d-8c41-004de444915c@googlegroups.com> <8e741582-e2a8-4713-b49d-6bd5a50a8317@googlegroups.com> <87h947e7f5.fsf@bsb.me.uk> <82f4ba9f-8d80-4769-842a-5a9b066efb5a@googlegroups.com> <5898e78d$0$18070$e4fe514c@newszilla.xs4all.nl> <3141f801-2946-40fc-87ad-97668f7061e4@googlegroups.com> <5012603.DvuYhMxLoT@PointedEars.de> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1486500870 32351 eJwFwYEBwDAEBMCVKvhnnBD2H6F3rhA0DQ7z9X1pwqngVzVyTDF5j+ZDZbiR3SLsHY061/QHFpUQ3A== (7 Feb 2017 20:54:30 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Tue, 7 Feb 2017 20:54:30 +0000 (UTC) User-Agent: KNode/4.14.2 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== X-NNTP-Posting-Host: eJwNysEBwCAIA8CVoEAi44DK/iPYe18YFJuOgMfEaB6TaqctAXVdObzT9VXmNjIlu73/TChDHg7TEEs= Cancel-Lock: sha1:qFBUYjVwNEpjsHUa0VCREik1GNs= X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. […] Thomas 'PointedEars' Lahn >> If something is to occur repeatedly in equal time *intervals*, then it >> might be better (depends on the use-case) and is certainly easier to call >> window.setInterval() once instead of window.setTimeout() several times. >> window.clearInterval() could then be called once the number of desired >> calls of the user-defined function has been reached. > > The rule of thumb and suggestion is to always use setTimeout (except maybe > for the very simplest cases, where it does not matter): I did say that it depends on the use-case, did I not? > the reason being that with setInterval one has to make sure that the > interval delay is not shorter than the job that has to be executed at > every interval, otherwise the browser chokes, Which browser, and how so? > and the way of ensuring that is to use setTimout instead... Depends. JFYI: You are preaching to the choir. I have advocated window.setTimeout() for years here, *for specific purposes*. -- PointedEars FAQ: | | Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.