Created
January 7, 2013 20:41
-
-
Save Grsmto/4478209 to your computer and use it in GitHub Desktop.
Javascript - "arguments.callee" technique : this value points to the anonymous function in which the code is executing.
This file contains 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
var todo = items.concat(); //create a clone of the original array | |
setTimeout(function(){ | |
//get next item in the array and process it | |
process(todo.shift()); | |
//if there's more items to process, create another timer | |
if(todo.length > 0){ | |
setTimeout(arguments.callee, 25); // arguments.callee = anonymous function where the code is executing | |
} else { | |
callback(items); | |
} | |
}, 25); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment