Skip to content

Instantly share code, notes, and snippets.

@Ajnasz
Created July 10, 2011 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ajnasz/1074795 to your computer and use it in GitHub Desktop.
Save Ajnasz/1074795 to your computer and use it in GitHub Desktop.
(function () {
var a = ['lorem', 'ipsum', 'dolor'];
var repeat = true;
var i = 0;
var f = function () {
console.log(a[i]);
var finished = i + 1 >= a.length;
if (!finished || repeat) {
i = finished && repeat ? 0 : i + 1;
setTimeout(f, 1000);
}
};
f();
}());
(function () {
var repeat = true;
var i = 0;
var f = function () {
console.log(i + 1);
var finished = i + 1 >= 10;
if (!finished || repeat) {
i = finished && repeat ? 0 : i + 1;
setTimeout(f, 1000);
}
};
f();
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment