I have an array like this:
var myArray = new Array();
myArray['foo'] = {
Obj: {
key: value
}
};
myArray['bar'] = {
Obj: {
key: value
}
};
When I do console.log(myArray), I'm just empty [ ]. And when I try to iterate through an array using jQuery each, the function does not start.
How can I get the parts "foo" and "bar" of an array?
Code example:
console.log(myArray);
jQuery.each(myArray, function(key, obj) {
console.log(key);
});
Also, why does this work:
jQuery.each(myArray[foo], function(obj, values) {
// Why does this work if there are no associative arrays in JS?
});
source
share