Nitpickery indeed, but that won't work as expected. `fn` can be reused within the loop, depending on the runtime, so all methods will end up calling the same `desk[fn]`.
Re:Do you know Ruby’s ‘Chainsaw’ method?
by warfangle on Thursday October 07, 2010 @11:22AM
(#1768133)
You're right in that it won't work as expected - unless the desk methods are static. In reality, you would probably want to call
desk[fn].call(thisContext, arguments);
Re:Do you know Ruby’s ‘Chainsaw’ method?
by sharkbrainguy on Thursday October 07, 2010 @06:59AM
(#1767438)
I think you might have misread the code.
Each `fn` is bound exactly once, `forEach` is not a loop.
Within the object constructor:
Granted, this doesn't get your methods on the prototype, and will incur a cost every time you create one of these objects. If you properly inherited from the desk class, it will overwrite them. And the emergency function will work just fine, if defined on desk.