Index: src/js/array.js |
diff --git a/src/js/array.js b/src/js/array.js |
index 8fe319e7ad30fb5bee5182848a1993eae76d0a4a..c28f96e8d94eaf3b0553a3abbb2d513804c63808 100644 |
--- a/src/js/array.js |
+++ b/src/js/array.js |
@@ -1489,6 +1489,47 @@ |
var length = TO_LENGTH(array.length); |
return InnerArrayFill(value, start, end, array, length); |
+} |
+ |
+ |
+function InnerArrayIncludes(searchElement, fromIndex, array, length) { |
+ if (length === 0) { |
+ return false; |
+ } |
+ |
+ var n = TO_INTEGER(fromIndex); |
+ |
+ var k; |
+ if (n >= 0) { |
+ k = n; |
+ } else { |
+ k = length + n; |
+ if (k < 0) { |
+ k = 0; |
+ } |
+ } |
+ |
+ while (k < length) { |
+ var elementK = array[k]; |
+ if (%SameValueZero(searchElement, elementK)) { |
+ return true; |
+ } |
+ |
+ ++k; |
+ } |
+ |
+ return false; |
+} |
+ |
+ |
+// ES2016 draft, section 22.1.3.11 |
+function ArrayIncludes(searchElement, fromIndex) { |
+ CHECK_OBJECT_COERCIBLE(this, "Array.prototype.includes"); |
+ |
+ var array = TO_OBJECT(this); |
+ var length = TO_LENGTH(array.length); |
+ |
+ return InnerArrayIncludes(searchElement, fromIndex, array, length); |
} |
@@ -1636,7 +1677,7 @@ |
"find", getFunction("find", ArrayFind, 1), |
"findIndex", getFunction("findIndex", ArrayFindIndex, 1), |
"fill", getFunction("fill", ArrayFill, 1), |
- "includes", getFunction("includes", null, 1) |
+ "includes", getFunction("includes", ArrayIncludes, 1), |
]); |
utils.InstallGetter(GlobalArray, speciesSymbol, ArraySpecies); |
@@ -1690,6 +1731,7 @@ |
to.InnerArrayFind = InnerArrayFind; |
to.InnerArrayFindIndex = InnerArrayFindIndex; |
to.InnerArrayForEach = InnerArrayForEach; |
+ to.InnerArrayIncludes = InnerArrayIncludes; |
to.InnerArrayIndexOf = InnerArrayIndexOf; |
to.InnerArrayJoin = InnerArrayJoin; |
to.InnerArrayLastIndexOf = InnerArrayLastIndexOf; |