# Returning the position of an element in an array

**URL:** <https://forum.kirupa.com/t/returning-the-position-of-an-element-in-an-array/149490>\
**Category:** flash\
**Created:** [May 29, 2005, 11:44pm UTC](https://forum.kirupa.com/t/returning-the-position-of-an-element-in-an-array/149490 "2005-05-29T23:44:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hgfl](https://avatars.discourse-cdn.com/v4/letter/h/8e7dd6/32.png) [@hgfl](https://forum.kirupa.com/u/hgfl)\
**Post date:** [May 29, 2005, 11:44pm UTC](https://forum.kirupa.com/t/returning-the-position-of-an-element-in-an-array/149490/1 "2005-05-29T23:44:36Z")

</div>

I’ve got an array (called “thearray”) that I’ve just sorted alphabetically using thearray.sort.  
I then wanted to check if a certain item (myItem) was in the array, so I did a loop:

for (var w=0; w\<thearray.length; w++){  
if (thearray[w]==myItem) trace(“this item has been found in the array”)

Now, I want to know if it’s possible to return the new position number of the item in the array - ie finding the element number of myItem (as in arrayelement[0], arrayelement[1], arrayelement[2]-- the number in the [].)

Does this make sense? If not I can explain further. Any help would be very much appreciated. Thanx.
