<offtopic> On Mon, Mar 19, 2012 at 2:23 PM, Krinkle <krinklem...@gmail.com> wrote:
> On Mon, Mar 19, 2012 at 9:35 AM, Daniel Friesen <li...@nadir-seen-fire.com > > wrote: > >> On Mon, 19 Mar 2012 00:40:54 -0700, Dmitriy Sintsov <ques...@rambler.ru> >> wrote: >> var jqgmap = []; >> >>> for ( var mapIndex in jqgmap ) { >>> >> >> This is VERY bad JavaScript coding practice. Please use $.each(). >> > > This is rather exaggerated. Even more when looking at that suggestion. > > Arrays should, indeed, not be enumerated with a for-in loop. Arrays in JS > can only contain numeral indices, so they should simply be iterated with a > > s/can/should only contain numeral indices. Arrays as just objects so they can indeed contain anything, and inherit functions. Also note that a for-in loop on arrays will return the keys as strings, not numbers: `var a = ['foo', 'bar']; for (var b in a) {}; console.log(typeof b, b /* "string", "1" */);` -- Krinkle _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l