Timeout Timeout Loop JavaScript

var keepCalling = true;

setTimeout(function () {
  keepCalling = false;
}, 10000);

while ( keepCalling ) {
  // do something
}
Hirokami