Well, should array.length do the trick or not? something like, I mean, you don’t need to know the range of indices if you just read it.
var arrayContainingObjects = []; for (var i = 0; i < arrayContainingYourItems.length; i++){ arrayContainingObjects.push {(property: arrayContainingYourItems[i])}; }
Perhaps I did not understand your question correctly, but you should be able to get the length of your array in this way and convert them to objects. Daniel gave the same answer, to be honest. You could just store the length of the array in your variable, and that will be done.
IF this should not happen, in my opinion, you cannot get the length of your array. As you said without getting the index number, you can do it like this:
var arrayContainingObjects = []; for (;;){ try{ arrayContainingObjects.push {(property: arrayContainingYourItems[i])}; } } catch(err){ break; }
This is not a good version above, but the loop will run until you “start” from the range of indices.
spitterfly Mar 18 '14 at 2:36 a.m. 2014-03-18 14:36
source share