Skip to content

Commit 191f458

Browse files
Fix incorrect results from Array#intersect. [#841 state:resolved] (Alexey Bass, Yaffle, Victor)
1 parent eac97a0 commit 191f458

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/prototype/lang/array.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ Array.from = $A;
358358
**/
359359
function intersect(array) {
360360
return this.uniq().findAll(function(item) {
361-
return array.detect(function(value) { return item === value });
361+
return array.indexOf(item) !== -1;
362362
});
363363
}
364364

test/unit/array_test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ new Test.Unit.Runner({
131131

132132
testIntersect: function(){
133133
this.assertEnumEqual([1,3], [1,1,3,5].intersect([1,2,3]));
134+
this.assertEnumEqual([0,1], [0,1,2].intersect([0,1]));
134135
this.assertEnumEqual([1], [1,1].intersect([1,1]));
135136
this.assertEnumEqual([], [1,1,3,5].intersect([4]));
136137
this.assertEnumEqual([], [1].intersect(['1']));

0 commit comments

Comments
 (0)