Index: src/array.js |
diff --git a/src/array.js b/src/array.js |
index e2aa4ad116724922d55dc7b9ffa129b967f23596..9cb6b6fdb31d03a624a626da232e822ae16f914d 100644 |
--- a/src/array.js |
+++ b/src/array.js |
@@ -994,11 +994,16 @@ function ArrayIndexOf(element, index) { |
// If index is still negative, search the entire array. |
if (index < 0) index = 0; |
} |
+ if (!IS_UNDEFINED(element)) { |
+ for (var i = index; i < length; i++) { |
+ if (this[i] === element) return i; |
+ } |
+ return -1; |
+ } |
// Lookup through the array. |
for (var i = index; i < length; i++) { |
- var current = this[i]; |
- if (!IS_UNDEFINED(current) || i in this) { |
- if (current === element) return i; |
+ if (IS_UNDEFINED(this[i]) && i in this) { |
+ return i; |
} |
} |
return -1; |
@@ -1018,10 +1023,15 @@ function ArrayLastIndexOf(element, index) { |
else if (index >= length) index = length - 1; |
} |
// Lookup through the array. |
+ if (!IS_UNDEFINED(element)) { |
+ for (var i = index; i >= 0; i--) { |
+ if (this[i] === element) return i; |
+ } |
+ return -1; |
+ } |
for (var i = index; i >= 0; i--) { |
- var current = this[i]; |
- if (!IS_UNDEFINED(current) || i in this) { |
- if (current === element) return i; |
+ if (IS_UNDEFINED(this[i]) && i in this) { |
+ return i; |
} |
} |
return -1; |