JavaScript function findIndex returns the index of first element which pass the test based on function. Here in this tutorial, we are going to explain how you can use this method to find the index of first element based on the provided function to check the array elements. You can also use our online editor to edit and run the example online.
Vue.js Array findIndex Method Example
You can get index of array element based on test in vuejs simply as below-
Example:
<div id="app"> <p>item 1 = {{ item1 }}</p> <p>Result = {{ elmnIndex }}</p> <button>Click Me</button> </div> |
Output of above example-