Index: src/js/array.js |
diff --git a/src/js/array.js b/src/js/array.js |
index a42aad590cd8a1905a29a16148544093a2e6d6ea..58e7f59e79811ef5929ec238a26d93255577c024 100644 |
--- a/src/js/array.js |
+++ b/src/js/array.js |
@@ -1257,10 +1257,19 @@ function InnerArrayForEach(f, receiver, array, length) { |
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f); |
var is_array = IS_ARRAY(array); |
- for (var i = 0; i < length; i++) { |
- if (HAS_INDEX(array, i, is_array)) { |
- var element = array[i]; |
- %_Call(f, receiver, element, i, array); |
+ if (IS_UNDEFINED(receiver)) { |
adamk
2016/02/18 17:43:32
FWIW we used to do something even fancier, but bme
Toon Verwaest
2016/02/24 09:09:03
That code was quite different. The bug there iirc
|
+ for (var i = 0; i < length; i++) { |
+ if (HAS_INDEX(array, i, is_array)) { |
+ var element = array[i]; |
+ f(element, i, array); |
+ } |
+ } |
+ } else { |
+ for (var i = 0; i < length; i++) { |
+ if (HAS_INDEX(array, i, is_array)) { |
+ var element = array[i]; |
+ %_Call(f, receiver, element, i, array); |
+ } |
} |
} |
} |