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
(function(){ | |
var i = 0; | |
var j = 0; | |
function forloop1(){ | |
if(i<10){ | |
j = 0; | |
forloop2(); | |
}else{ | |
console.log("all done"); | |
} |
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
for(var i=0; i<5; i++){ | |
for(var j=0; j<5; j++){ | |
for(var k=0; k<5; k++){ | |
for(var m=0; m<5; m++){ | |
console.log(i,j,k,m); | |
} | |
} | |
} | |
} |
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
(function(){ | |
var i = 0; | |
var j = 0; | |
var k = 0; | |
var m = 0; | |
function forloop1(){ | |
if(i<5){ | |
j = 0; | |
forloop2(); | |
}else{ |
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
function loop(init, fnCondition, fnUpdate, fnRun, fnDone){ | |
var index = 0; | |
index = (init.constructor.name === "function")?init():init; | |
function next(){ | |
index = fnUpdate(index); | |
if(fnCondition(index)){ | |
setTimeout(function(){ | |
fnRun(index, next); | |
}, 0); | |
}else{ |
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
// Single for loop (i) | |
// i loop | |
loop(0, function(i){return i<10;}, function(i){return i+1;}, | |
function(i, next){ | |
// looping. | |
console.log(i); | |
next(); | |
}, | |
function(i){ console.log("all done."); } | |
); |
OlderNewer