Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

5. Collections and Iterations > Wrapping Up - Pg. 120

120 Chapter 5 Collections and Iterations So how do we prevent this from happening and keep track of the variable's value that we actu- ally want? We can do this using the do keyword: Example: (source: do2.coffee) for x in [1..5] do (x) -> setTimeout -> console.log x , 1 Example: (source: do2.js) (function() { var x, _fn; _fn = function(x) { return setTimeout(function() { return console.log(x); }, 1); };