Created
June 4, 2013 19:47
-
-
Save aach/5708936 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function async( fn ) | |
{ | |
window.setTimeout( fn, 0 ); | |
} | |
function problem() | |
{ | |
for( var i = 0; i < 10; i++ ) | |
{ | |
async( function () | |
{ | |
console.log( i ); | |
} ); | |
} | |
} | |
function solution() | |
{ | |
for( var i = 0; i < 10; i++ ) | |
{ | |
( function( i ) | |
{ | |
async( function () | |
{ | |
console.log( i ); | |
} ); | |
}( i ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good solution ;)