I tried to understand of how deferred works,so in all of them they use setTimeout
.
this.callbacks;// array of functions reference
this.callbacks.forEach(function(callback){
window.setTimeout(function(){
callback(data);
},0);
});
one example from this questions that use setTimeout
resolve: function (data) {
this.promise.okCallbacks.forEach(function(callback) {
window.setTimeout(function () {
callback(data)
}, 0);
});
},
What is the different between calling functions in loop by setTimeout
than callback();
or callback.call();