Thread:Mathmagician/@comment-3508190-20120504092551/@comment-4674838-20120504221002

It appears I have much more learning to do! In C++ or Java, an object is an instantiated class consisting of data and functions. To say that a function IS an object will take some getting used to. (Although since you can assign a function to a variable, it makes sense that you would be able to pass functions to other functions.)

The example you just gave gives me some interesting things to think about though. counter is like a variable of some unspecified type which corresponds to the type of the object/function. Calling the anonymous function seems similar to using a constructor. The object itself contains (private) data c and (public) methods inc and log. -- If I think about it this way, it makes sense that c outlives the function in which it is declared. Because the counter object itself still persists.

The lack of types still confuses me, however: return { inc: function { c++; },       log: function  { console.log(c); }   }; What data type exactly is being returned? An array of functions?

I will certainly look more into event handling. I've done some before when writing Java GUIs, so the concept of an asynchronous program is not entirely foreign to me. I'm just not used to really thinking about it too much. I'm so used to think about everything in terms of data first, and then which methods I need to manipulate that data. An event handler to me is just something I have to think about only at the end -- a method that calls methods which I've already written to accomplish whatever task.