How to get array keys in Javascript?

Posted by DisgruntledGoat on Stack Overflow See other posts from Stack Overflow or by DisgruntledGoat
Published on 2010-03-24T16:26:26Z Indexed on 2010/03/24 16:33 UTC
Read the original article Hit count: 204

Filed under:
|
|

I have an array created with this code:

var widthRange = new Array();
widthRange[46] = { sel:46, min:0,  max:52 };
widthRange[66] = { sel:66, min:52, max:70 };
widthRange[90] = { sel:90, min:70, max:94 };

I want to get each of the values 46, 66, 90 in a loop. I tried for (var key in widthRange) but this gives me a whole bunch of extra properties (I assume they are functions on the object). I can't use a regular for loop since the values are not sequential.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about array