mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Coerce indexOf fromIndex parameter to integer (#4410)
This commit is contained in:
committed by
John-David Dalton
parent
4f68e93a43
commit
ff4949b8c2
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user