I have a JS-hash containing a key length (which represents something completely different than the length of the hash) and need to iterate over it.
The problem is that jQuery.each is refusing to iterate over this since it detects the length attribute and figures that it must be an array or array-like object.
From the jQuery documentation:
Arrays and array-like objects with a length property (such as a function’s arguments object) > are iterated by numeric index, from 0 to length-1. Other objects are iterated via their
named properties.
This JS fiddle illustrates the problem.
Well, so it’s all documented and understandable. But how to proceed if I just have an attribute named length? Do I have to do a painful renaming before and after iterating the hash, or is there any possibility of telling jQuery to just ignore this property and treat it like any other object attribute?
Thank’s a lot in advance!
How about not using jquery.each but…
UPDATED
forgot to sanitise the loop with “hasOwnProperty” just in case…