TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

JavaScript TypedArray findIndex() Method

JavaScript TypedArray findIndex() Method with example, join() method, javascript typedarray methods, keys() method, indexOf() method, includes() method, forEach() method, entries(), every(), find(), filter(), copyWithin() method etc.

<< Back to JAVASCRIPT

JavaScript TypedArray findIndex() Method

The JavaScript findIndex() method provides the index of the first element in the array that completes the given test. If the test is not satisfied, it will return -1.

  • findIndex() does not execute the function for array elements without values.
  • findIndex() does not change the original array.

Syntax:

array.findIndex(function(Value, index, arr) thisValue)

Parameters:

Value: The value of the current element.

Index: The array index of the current element.

Arr: The array object on which the findIndex() method operated.

ThisValue: A value to be passed to the function to be used as its "this" value. If the parameter is empty, the value "undefined" will be passed as its "this" value.

Return value:

Index of the array element, otherwise it returns -1.

Browser Support:

Chrome 45.0
Edge 7.1
Firefox 25.0
Opera 32.0

Example 1

JavaScript TypedArray findIndex() Method

<script type="text/javascript">
// JavaScript to illustrate findIndex() method
function JavaTpoint(value)
{
return value >34;
}
 // Input array
var arr = [1,2,3,4,5,6,7,8,9,12,11,14];
var result = arr.findIndex(JavaTpoint);
document.write(result)// expected output: arr[Output:-1] 
</script> 
Test it Now

Output:

-1

Example 2

JavaScript TypedArray findIndex() Method

<script type="text/javascript">
//JavaScript to illustrate findIndex() method
function JavaTpoint(value)
{
return value ==6;
}
 // Input array
var arr = [1,2,3,4,5,6,7,8,9,12,11,14];
var result = arr.findIndex(JavaTpoint);
document.write(result) 
// expected output: arr[Output:5]
</script> 
Test it Now

Output:

5





Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf