I am trying to make a function called methodgetter.  This is similar to
itemgetter but calls an object method rather than returning an object
property.  For the most part, the following code works:
function methodgetter(name) {
    return function(object){ return object[name].call(object); }
}

But I also want to use map with multiple arguments like so:
map(methodgetter('aMethod'), objectArray, methodArgumentArray);

I had to modify the closure to look like:
function methodgetter(name) {
    return function(object, a){ return object[name].call(object, a); }
}

I thought it would be possibly to extend this to many arguments by
using:
function methodgetter(name) {
    return function(object){ return object[name].apply(object,
arguments); }
}

However, this does not work.  Am I missing something with the use of
the javascript arguments variable?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to