Last active
August 30, 2016 02:45
-
-
Save jonlow/c110a4952bd3ec5e91d3 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
var aFunc = []; | |
function callback(delay) { | |
setTimeout(function() { | |
if (aFunc.length > 0) { | |
console.log(aFunc.length) | |
aFunc[0](); | |
aFunc.shift(); | |
} else { | |
console.log('end'); | |
} | |
}, delay) | |
} | |
var an1 = function() { | |
callback(100) | |
} | |
var an2 = function() { | |
callback(2000) | |
} | |
var an3 = function() { | |
callback(600) | |
} | |
aFunc = [an1, an2, an3]; | |
callback(1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment