I am currently facing an issue with adding a JSON object based on specific conditions to an array, which is then used to create a WINJSList. The problem arises when I try to access the elements of the list or array after using the array.push method. My goal is to verify that the additions are being done correctly. Any assistance on this matter would be highly appreciated. Here is the code snippet:
var names_Array = new Array;
var names_List = new WinJS.Binding.List(names_Array);
if (condition) {
if (condition) {
names_List.push({
name: "Joe Dowling",
image: "image/Joe Dowling.png",
ClientID: "1234"
});
} else if (condition) {
names_List.push({
name: "Esteban Flamenco ",
image: "image/Esteban Flamenco.png",
ClientID: "6666"
});
} else if (condition) {
names_List.push({
name: "Plain Jane ",
image: "image/Plain Jane.png",
ClientID: "0000"
});
}
console.log(names_Array);
console.log(names_Array[0]);
console.log(names_List);
console.log(names_List[0]);
I have also attempted:
var names_Array = new Array;
if (condition) {
if (condition) {
names_Array.push({
name: "Joe Dowling",
image: "image/Joe Dowling.png",
ClientID: "1234"
});
} else if (condition) {
names_Array.push({
name: "Esteban Flamenco ",
image: "image/Esteban Flamenco.png",
ClientID: "6666"
});
} else if (condition) {
names_Array.push({
name: "Plain Jane ",
image: "image/Plain Jane.png",
ClientID: "0000"
});
}
var names_List = new WinJS.Binding.List(names_Array);
When checking the console, I encounter issues where I either see undefined or [object object].