See the complete code example below to get and show the result in the console log:
var animals = ["Cat", "Dog", "Donkey", "Monkey", "Cow", "Goat"]; var arrIndex = animals.indexOf("Monkey"); console.log(arrIndex);
In the above example, we are able to do our task successfully. First of all, we take an array and assigned it inside the variable animals. As you can see, the array contains some animal names as items. From the items, we find the index number of “Monkey” to get the position.
That’s it. So easy… I hope, you have learned something new in a simple way from this article.