TheDeveloperBlog.com

Home | Contact Us

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

JavaScript TypedArray indexOf() Method

JavaScript TypedArray indexOf() 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 indexOf() Method

The JavaScript indexof() Method is used to find the index of the element provided as the argument to the function.

  • The indexof() method is case sensitive.

Syntax:

Array.indexof(value, start) 

Parameters:

Value: Value to be search in the index.

Start: Default 0. At which position to start the search.

Return value:

It returns the index of the search element. If the element cannot to be found in the array, this method returns -1.

Browser Support:

Chrome Yes
Edge Yes
Firefox Yes
Opera Yes

Example 1

JavaScript TypedArray indexOf() Method

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

Output:

-1

Example 2

JavaScript TypedArray indexOf() Method

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

Output:

4





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