I have a for loop in JS when I set a breakpoint inside the for a loop the index set it has a value in one usage but the other says undefined.
I have a breakpoint set at the line that starts $("#send_hour option")
If I mouseover index in the for(index in availablehours)
it shows 09. If I mouseover index at the end index);
it also shows 09. But if I mouseover index here availablehours[index]
it shows as undefined?
var availablehours = {
"09" : '9AM',
"10" : '10AM',
"11" : '11AM',
"12" : 'Noon',
"13" : '1PM',
"14" : '2PM',
"15" : '3PM',
"16" : '4PM',
"17" : '5PM',
"18" : '6PM',
"19" : '7PM'
};
How is this possible?
function refreshTheSendHoursWithAvailableHours(){
console.log( "refreshTheSendHoursWithAvailableHours just called.");
for(index in availablehours) {
$("#send_hour option")[ $("#send_hour option").length] = new Option(availablehours[index], index);
}
}