Does javascript have a sort of event listeners?
My scenario:
I want to execute Inc function 2 times with different parameters, first execution of Inc and then the second execution, but the second execution must be executed after X seconds (settimeout...) after the first Inc function is completed (all it's iterations, as soon as clearInterval ).
So I need sort of event and a listener (of-course it must be asynchronous).
What can you suggest? (please no jquery...)
function Inc(val1,val2){
var intervalID = setInterval(function(){
if (val1 > val2) clearInterval(intervalID);
val1= val1 + 10;
}, 400);
}