Add support for _.invoke() to take function reference.

This commit is contained in:
aseemk
2011-03-25 12:35:11 -07:00
parent de50fc4607
commit 3f512c2495
2 changed files with 20 additions and 20 deletions

View File

@@ -208,7 +208,7 @@
_.invoke = function(obj, method) {
var args = slice.call(arguments, 2);
return _.map(obj, function(value) {
return (method ? value[method] : value).apply(value, args);
return (typeof method === "string" ? value[method] : method || value).apply(value, args);
});
};