Q:

Why use setTimeout in deferred

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(); 

A:

The reason for doing this is to allow the javascript thread an opportunity to trigger any other events that may be waiting in the queue.
Javascript is single-threaded. If an event is triggered, it can only run when the currently running code has finished.
Using setTimeout with a zero time delay effectively tells the JS interpreter that the callback function call is part of a new context and that your current code block is finished. This means that JS will take the opportunity before calling callback() to check to see if any other events need to be handled.
Although this may delay callback() itself from being called immediately, this can be good for your site's overall performance:
Other events that may need to be handled include click events and other UI triggers. If you don't give them a chance to execute, it may make your user interface appear sluggish or non-responsive.

