indexOf:To check if an item exist in an array. If it exists it returns the index else it returns -1.

PHOTO EMBED

Fri Sep 16 2022 13:05:41 GMT+0000 (Coordinated Universal Time)

Saved by @sreejithbs

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

console.log(numbers.indexOf(5)) // -> 4
console.log(numbers.indexOf(0)) // -> -1
console.log(numbers.indexOf(1)) // -> 0
console.log(numbers.indexOf(6)) // -> -1
content_copyCOPY

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