I am trying to loop through an array. I have the following code:
var substr = currnt_image_list.split(','); //This will split up 21,32,234,223,
Am trying to get all the data out of the array. Can some one lead me in the right path please?
|
(Update: My other answer here lays out the non-jQuery options much more thoroughly. The third option below, Three options: Generic loop:
Advantages: Straight-forward, no dependency on jQuery, easy to understand, no issues with preserving the meaning of ES5's
|
|
using
.each() or for...in to loop over an array is in general a bad idea. It's just like ages slower than using for or while . Using a for loop it's even a great idea to cache the length property before looping. for (var i = 0, len = substr.length; i < len; ...
– jAndy
Oct 15 '10 at 15:15
|
||
|
@jAndy: I believe I did mention speed being an advantage of the first one. Re caching the length, it would have to be a REALLY big array to be worth the overhead, but fair 'nuff.
– T.J. Crowder
Oct 15 '10 at 15:24
|
||
|
|
|||
|
No need for jquery here just a
|
|||
|
Use the Here is an example:
|
|||
|
You can use a
|
|||
|
Use Jquery each. There are other ways but each is designed for this purpose.
And do not put the comma after the last number. |
|||
|