Loop forever and provide delta time
问题 I'm writing an HTML5 Game Development Javascript framework and I want to provide the user the difference in time between the last tick and the current one. setInterval(tick, 16.6666666); function tick() { update(); draw(); } That's what I have, but I want to have: while (true) { /* Calculate delta time */ tick(dt); } function tick(dt) { update(dt); draw(); } I tried that, using date.getTime(); to calculate delta time, but Firefox said the script crashed. Obviously, an infinite loop will crash