# Array Vs Object Speed

**URL:** <https://forum.kirupa.com/t/array-vs-object-speed/280984>\
**Category:** flash\
**Created:** [February 3, 2009, 6:19pm UTC](https://forum.kirupa.com/t/array-vs-object-speed/280984 "2009-02-03T18:19:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![drexton](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@drexton](https://forum.kirupa.com/u/drexton)\
**Post date:** [February 3, 2009, 6:19pm UTC](https://forum.kirupa.com/t/array-vs-object-speed/280984/1 "2009-02-03T18:19:22Z")

</div>

Howdy folks

I have a little utility takes lists of letters, combines them in every possible permutations, and lists out all the combinations that are words. For example, I would feed it in “cde,abc,tbrn” and it would let me know that cat, cab, car, can, dab, eat, ear, and ebb are all valid words.

I’ve tried two different approaches:

Load a dictionary text file, and splice it into dict:Array. For each possible letter combination run:

if(dict.indexOf(testWord)!=-1) trace(testWord);

The other option is to convert dict:Array into an dictionary:Object  
for (i=0; i\<dict.length; i++){dictionary[(dict\*)] = dict\*;}

and then run:  
if(dictionary[testWord]) trace(testWord);

Although I’ve read arrays are faster than objects, testing to see if the word exists in an object, and iterating 10s to 100s of times over a several thousand word dictionary is orders of magnitude faster than checking to see if the word exists in the dict:Array.

Any thoughts on why this is, and any thoughts on how to do it better?

Thanks
