How to find the index of the last occurrence of an element in array with JavaScript

1 Answer

0 votes
var arr = ["javascript", "c", "python", "php", "c++", "java"];

var lastIndex = arr.lastIndexOf("c");

console.log(lastIndex); 

  
    
    
/*
run:
    
1
    
*/

 



answered Feb 15, 2021 by avibootz
...