Make a flowchart to demonstrate closure behavior
Posted
by
thomas
on Programmers
See other posts from Programmers
or by thomas
Published on 2013-06-24T19:21:56Z
Indexed on
2013/06/24
22:30 UTC
Read the original article
Hit count: 268
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.
© Programmers or respective owner