1. Expectation: When
we manipulate the array, we need to get the index value of the target value, and then perform the corresponding operation.
2. This method is provided in es6 findIndex
;
3.
Definition and usage The
findIndex() method returns the position of the first element of the array that passes a test condition (function) that meets the condition.
The findIndex() method calls the function once for each element in the array:
When the element in the array returns true when the condition is tested, findIndex() returns the index position of the element that meets the condition, and the execution function will not be called for the subsequent values.
If there are no eligible elements, return -1.
Note: findIndex() will not be executed for empty arrays.
Note: findIndex() does not change the original value of the array.
4. findeIndex
Receive three parameters,
function(currentValue, index,arr) 必须。数组每个元素需要执行的函数。
函数参数:
参数 描述
currentValue 必需。当前元素
index 可选。当前元素的索引
arr 可选。当前元素所属的数组对象
```js
5、参数是一个回调函数,类似于map,forEach的写法。
```js
const index = likerList.findIndex((item) => {
return item.senderAccountId === accountId;
})
6. What can be further studied and compared is to operate on arrays
find() map() forEach() fliter()