So, I have an array that contains X objects, all named by dates and containing useless data beyond their name.
I want to store these dates in an array for later use and objects are, apparently, not found in an array by array[i], so how do I iterate through the array and just save the names to a string in another array?
Edit: Ok this question was due to a major brainfart… The obvious answer would be
var dP = $('#calendar').GetDate();
var dPTmp = [];
var i = 0;
for (var id in dP) {
dPTmp[i] = dP[id].toString();
i++;
}
console.log(dPTmp);
As elusive stated in comments, you’re not dealing with an
Arraybut with anObject.However, the construct you’re probably looking for is the
for..instatement that lets you loop through the object’s properties.Something along these lines:
Also note that you can’t trust that the object’s properties will be iterated “in order”. See this question.