Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Asynchronous JavaScript

Lean Machine
September 04, 2013

Asynchronous JavaScript

Lean Machine

September 04, 2013
Tweet

More Decks by Lean Machine

Other Decks in Programming

Transcript

  1. var  printRandoms  =  function(n)  {    var  randoms  =  [];

       for  (  var  i=0;  i<n;  i++  )  {        randoms.push(Math.random());    }    asyncForEach(randoms,  function(rand,  callback)  {        setTimeout(function()  {            console.log("..  "  +  rand);            callback();        },  rand  *  1000);    },  function()  {        console.log("done");    }); };