Which of the following methods is used to find the index of an element in an array in JavaScript?
a)
indexOf()
b)
findIndex()
c)
find()
d)
search()
Answer:
a)
indexOf()
Explanation:
The indexOf()
method returns the first index at which a given element can be found in an array, or -1
if the element is not present. It is useful for locating elements in arrays.