lastIndexOf: It gives the position of the last item in the array. If it exist, it returns the index else it returns -1.

PHOTO EMBED

Fri Sep 16 2022 13:06:14 GMT+0000 (Coordinated Universal Time)

Saved by @sreejithbs

const numbers = [1, 2, 3, 4, 5, 3, 1, 2]

console.log(numbers.lastIndexOf(2)) // 7
console.log(numbers.lastIndexOf(0)) // -1
console.log(numbers.lastIndexOf(1)) //  6
console.log(numbers.lastIndexOf(4)) //  3
console.log(numbers.lastIndexOf(6)) // -1
content_copyCOPY

https://github.com/Asabeneh/30-Days-Of-JavaScript/blob/master/05_Day_Arrays/05_day_arrays.md