TheDeveloperBlog.com

Home | Contact Us

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

JavaScript TypedArray lastIndexOf() Method

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

The JavaScript lastIndex()of method returns the last position of a value, or it returns -1 if the value is not found.

NOTE: The string is searched from the end to the beginning, but returns the index starting from the beginning, at position 0.

The lastIndexof() method is case sensitive.

Syntax:

array.lastIndexOf(value, start) 

Parameters:

Value: The first parameter is value that is going to be searched in the array.

Start: It refers the position where to start the search. If the value is not given in the argument, the default value is the length of the array.

Return value:

Representing the index of the element where the value is found for the last time, or -1 if the value cannot be found.

Browser Support:

Chrome Yes
Safari Yes
Firefox Yes
Opera

Example

JavaScript lastIndexOf() Method

<script type="text/javascript">
 // JavaScript to illustrate lastIndexOf() method
function JavaTpoint() {
    // string
    var str = 'JavaTpoint'; 
    //Finding the index of the string
    var index = str.lastIndexOf('T');
    document.write(index);
}
JavaTpoint();
// expected output: arr[Output:4]
</script>
Test it Now

Output:

4

Example 2

JavaScript lastIndexOf() Method

<script type="text/javascript">
 // JavaScript to illustrate lastIndexOf() method
function JavaTpoint() {
// string
 var str = 'JavaTpoint';
 //Finding the index of the string
 var index = str.lastIndexOf('s');
 document.write(index);
}
JavaTpoint();
// expected output: arr[Output:-1]
</script>
Test it Now

Output:

-1





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