Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

JobQueue in Javascript

DZone's Guide to

JobQueue in Javascript

·
Free Resource

My code snippet is a very easy and simple form of execute a jobs in javascript. it could use to organize a XMLHttpRequest's

view more info luis.caribecoders.com

function function1(){  // Function #1
 alert('Hello');
}

function function2(){  // Function #1
 alert('World');
}

var queue= [];                     // <- This is a Vector in this case a queue representation.
 queue.push(function1);      // <- storage a function #1 in a queue vector.
 queue.push(function2);      // <- storage a function #2 in a queue vector.
   while (cola.length > 0) {   // <- iterate a queue vector and execute the functions.
      (queue.shift())();            // <- Excecute the process. 
    }
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}