Hello,
I am looking over code plus the concept of closures. Below is the code:
Closures are a powerful tool but can be tricky to understand. Mastering them, however, will allow you to write some very elegant code.
Here’s an example:
var saver = function (value) { return function () { return value; };};var retriever = saver(10);alert(retriever());
So the code alerts 10. If you rewrite the last line to be console.log(retriever);
You get this:
function () { return value; }
I can watch the original code execute in Chrome Debugging Tools, but it doesn't help to understand it.
Does anyone know I resource where I can watch say a table where the functions get created and variables get passed? Or can you create the table right here?
Years ago a read a book about C and the author used tables to simulate memory locations for say functions, pointer to functions, variables and
passing values by reference, etc.
Thanks,
Jim