From ff4949b8c209bb0779f86fe3d07e88d7a4ccc47a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Am=C3=A9rico?= Date: Fri, 16 Aug 2019 14:56:41 -0300 Subject: [PATCH] Coerce indexOf fromIndex parameter to integer (#4410) --- indexOf.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/indexOf.js b/indexOf.js index f5fe63110..358fff4cc 100644 --- a/indexOf.js +++ b/indexOf.js @@ -1,4 +1,5 @@ import baseIndexOf from './.internal/baseIndexOf.js' +import toInteger from './toInteger.js' /** * Gets the index at which the first occurrence of `value` is found in `array` @@ -26,7 +27,7 @@ function indexOf(array, value, fromIndex) { if (!length) { return -1 } - let index = fromIndex == null ? 0 : +fromIndex + let index = fromIndex == null ? 0 : toInteger(fromIndex) if (index < 0) { index = Math.max(length + index, 0) }