What is lastIndexOf in javascript?

 Array lastIndexOf method javascript:


lastIndexOf() method find a position for all defined element but it's count only the last index. And if we will not find the given value it will be returned -1. Also, you can know about indexOf().

Syntax of lastIndexOf method:



lastIndexOf example in javascript:


const colors = ["Red", "blue", "Black", "Red", "Orange", "White"];



// 3



// -1


No comments:

Note: Only a member of this blog may post a comment.

Copyright Reserved to Anything Learn. Powered by Blogger.