I created an object that contains several elements, including one that contains several objects, each of which contains an array. This is how it is structured.
$.myVar = {
cp : "",
ps : {
m1 : ["001", "002", "003"],
m2 : ["002", "004"]
}
};
My scripts continue to crash, saying that $ .myVar.ps ["m1"] does not have a method each.
When I hit the Chrome console for research, I run the following and get the displayed output.
$.myVar.ps["m1"]
["001", "002", "003"]
$.myVar.ps["m1"].each( function (i, p) {alert(i)})
TypeError: Object 001,002,003 has no method 'each'
Also, if I run the following, this proves that m1 is an array.
$.isArray($.myVar.ps["m1"])
true
So it looks like m1 is an array, but he refuses to treat it as such. Any idea what I'm doing wrong?
source
share