Wednesday, May 27, 2015

5/26/15 - Neat Closure Scope

I did something cool today!  In NotesDemo, I wanted to move this click event out of $(document).ready into an object, but the click event needs access to the notes_make object.  After reading JavaScript: The Good Parts, I knew that I could create a function that returns another function, which I did here.  This puts the object passed into the function as notes_make within the scope of the returned function!  Then I can do this, as notes_make is accessible inside the returned function!

No comments:

Post a Comment