Hello all,
I have been trying to understand how JavaScript closures work but I have been struggling. In this code snippet that I created to test things, I can't figure out how to change the value of the variable a to "b" without passing an argument into the function or returning the value. Can someone please help? Also, does anyone know of a site that explains closures in simple detail? Thanks.
I have been trying to understand how JavaScript closures work but I have been struggling. In this code snippet that I created to test things, I can't figure out how to change the value of the variable a to "b" without passing an argument into the function or returning the value. Can someone please help? Also, does anyone know of a site that explains closures in simple detail? Thanks.
Code:
function a() { var a = "a"; blah = function() { a = "b"; } alert(a); }
Comment