Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

findindex js

// 	findIndex(callback fn)  

//	.... return index (when condition meets)
//  .... return -1 (if condition not meets)

const array = [5, 12, 8, 130, 44];

/// it returns the index of number which satisfy the condition true
const index = array.findIndex((item)=> item>10);   //1

/// now we can check what element at that index...
console.log(array[index]); // array[1]
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #findindex #js
ADD COMMENT
Topic
Name
8+1 =