Know position in array from object

So I do


var myArray = [];
myArray[6] = new myClass();

How can I know from myClass in what position it is in the array?

I usually do it like this:


myArray[6] = new myClass({id:6});

But is there some other cleaner way of doing it?

I tried indexOf but always returns -1…

TIA