DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Luis has posted 1 posts at DZone. View Full User Profile

JobQueue in Javascript

07.08.2013
| 3562 views |
  • submit to reddit
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. 
    }

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