Skip to content

Instantly share code, notes, and snippets.

@tarnfeld
Forked from m4tthumphrey/gist:5115996
Last active December 14, 2015 16:38
Show Gist options
  • Save tarnfeld/5116063 to your computer and use it in GitHub Desktop.
Save tarnfeld/5116063 to your computer and use it in GitHub Desktop.
var a = [], i = 0;
function addPart(part, callback) {
setTimeout(function(part) {
a.push(part);
callback();
}, 200);
};
function init(callback) {
function check() {
i++;
if (i == 2) {
callback();
}
};
addPart("hi", check);
addPart("ho", check);
};
init(function() {
alert(a.length);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment