Make a flowchart to demonstrate closure behavior
- by thomas
I saw below test question the other day in which the author's used a flow chart to represent the logic of loops. And I got to thinking it would be interesting to do this with some more complex logic. For example, the closure in this IIFE sort of boggles me.
while (i <= qty_of_gets) {
// needs an IIFE
(function(i)
promise = promise.then(function(){
return $.get("queries/html/" + product_id + i + ".php");
});
}(i++));
}
I wonder if seeing a flowchart representation of what happens in it could be more elucidating. Could such a thing be done? Would it be helpful? Or just messy? I haven't the foggiest clue where to start, but thought maybe someone would like to take a stab. Probably all the ajax could go and it could just be a simple return within the IIFE.