
array.findIndex() – Returns the **index** of the first element that satisfies the testing function or `-1`.
๐ Syntax
index = array.findIndex((element, index, array) => {
return /* condition */;
}, thisArg);
๐งช Example
const nums=[4,9,16];
console.log(nums.findIndex(n => n > 10)); // 2
Comments
Post a Comment