I'm getting a length of 0 for the incoming array to this method below and undefined for the array properties that's being passed in below and not sure why:
function BindAlbumDropdownList(aAlbums, defaultAlbumID)
{
if(aAlbums.length == 0)
return;
var albumDropdownID = $("#abumDropdown").attr("id");
AddDropdownItem("-Select an Album-", "-1", "albumDropdown");
for(var a in aAlbums)
{
alert("a.name, a.id, albumDropdown: " + a.name + "|" + a.id + "|" + albumDropdownID);
AddDropdownItem(a.name, a.id, albumDropdownID);
}
}
I'm passing in an array that was defined earlier in another method that calls this method and the array was defined and passed like this:
var aAlbums = GetAllAlbums(userID, accessToken);
var defaultAlbumID = aAlbums[0].id;
BindAlbumDropdownList(aAlbums, defaultAlbumID)
GetAllAlbums is returning a variable setup like this inside it:
var aFacebookAlbums = []; // array
and returns this array once populated.
but when I enter the for loop in the BindAlbumDropdownList, I'm getting undefined for the array properties as well as the check for length is zero
here's what the alert is giving me:
a.name, a.id, albumDropdown: undefined|undefined|albumDropdown
I am positive GetAllAlbums is returning an array with values in it because
var defaultAlbumID = aAlbum[0].id; gives me a valid value
I noticed that it seems like BindAlbumDropdownList doesn't really know the incoming aAlbums is an array even though I am passing an array to it. Because I'm getting no intellisense showing the property array when trying to do aAlbum.length but I do get the .length property on the array just before I return it from the GetAllAlbums function.