Fastest way to find item in array/object

actionscript-3, arrays, javascript

Solution

Using an object doesn't sound like a good idea, as re-indexing will be a heavy operation and will wipe out the access performance gains if any. Array.indexOf(x) seems to be the way to go.

Problem

What's the fastest way to find the index of an item in a list or object in Javascript / AS3? I'm asking this for both because the syntax is similar for both these languages. Assuming: ``` myArray = ["one", "two", "three"]; myObject = {one:1, two:2, three:3}; ``` Which is the fastest and in which case would you want it or not? - Array.indexOf(x) - myObject[x] != null - x in myObject - something else?

Original source