what does run to completion mean code example
Example: what does run to completion mean
RUN TO COMPLETION
once the function starts running,
it will always run to completion before any other JS code can run.
Example:
setTimeout(function(){
console.log("Hello World");
},1);
function foo() {
// NOTE: don't ever do crazy long-running loops like this
for (var i=0; i<=1E10; i++) {
console.log(i);
}
}
foo();
// 0..1E10
// "Hello World"