# Know position in array from object

**URL:** <https://forum.kirupa.com/t/know-position-in-array-from-object/319666>\
**Category:** Uncategorized\
**Created:** [February 28, 2011, 9:43pm UTC](https://forum.kirupa.com/t/know-position-in-array-from-object/319666 "2011-02-28T21:43:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pier25](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pier25](https://forum.kirupa.com/u/Pier25)\
**Post date:** [February 28, 2011, 9:43pm UTC](https://forum.kirupa.com/t/know-position-in-array-from-object/319666/1 "2011-02-28T21:43:27Z")

</div>

So I do

```auto

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:

```auto

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

```

But is there some other cleaner way of doing it?

I tried indexOf but always returns -1…

TIA
