Is there a JavaScript function for returning the index of an element I clicked? [closed]

Suppose I click on a html element that isn’t in an array, and I want to know its index. For example the index of a h1 element. How do I get that with JavaScript?