Can anybody explain to me why the following code is producing an infinite loop?
var car = 'Ford';
var done = false;
setTimeout(function() {
car = 'Toyota';
done = true;
}, 500);
while (!done) {}
alert(car);
Update:
Answered here as well.