First of all , i know that JavaScript is single threaded. Lets say i have a counter that outputs its values every second.
var counter = 0;
setInterval(function(){
console.log("Interval: " + ++counter);
}, 1000);
At some point, i want to trigger some code that halts the execution of the script. For example, an alert message.
setTimeout(function(){
alert("Some alert message");
},10000);
At this point when the alert message popped, the interval code will halt. Is there a trick so it will not stop executing?