We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e58af52 + 2206092 commit 66bb646Copy full SHA for 66bb646
test/collections.js
@@ -180,6 +180,19 @@ $(document).ready(function() {
180
equals(result[1].join(', '), '1, 2, 3', 'second array sorted');
181
});
182
183
+ // Relevant when using ClojureScript
184
+ test('collections: invoke when strings have a call method', function() {
185
+ String.prototype.call = function(){return 42;}
186
+ var list = [[5, 1, 7], [3, 2, 1]];
187
+ var s = "foo";
188
+ equals(s.call(), 42, "call function exists");
189
+ var result = _.invoke(list, 'sort');
190
+ equals(result[0].join(', '), '1, 5, 7', 'first array sorted');
191
+ equals(result[1].join(', '), '1, 2, 3', 'second array sorted');
192
+ delete String.prototype.call;
193
+ equals(s.call, undefined, "call function removed");
194
+ });
195
+
196
test('collections: pluck', function() {
197
var people = [{name : 'moe', age : 30}, {name : 'curly', age : 50}];
198
equals(_.pluck(people, 'name').join(', '), 'moe, curly', 'pulls names out of objects');
underscore.js
@@ -218,7 +218,7 @@
218
_.invoke = function(obj, method) {
219
var args = slice.call(arguments, 2);
220
return _.map(obj, function(value) {
221
- return (method.call ? method || value : value[method]).apply(value, args);
+ return (_.isFunction(method) ? method || value : value[method]).apply(value, args);
222
223
};
224
0 commit comments