I have an array called fillet_array, which contains objects (currently there is only one object, but this changes throughout the program). This is the output in Chrome:
0: Object
cid: "9351"
imgsrc: "1a4b1ebb4a31e2104ec1f2bab8539731"
index: 0
sku: "TD00060S0"
width: 0.31
This is my code (Note at this time mattes_number_layers
is 2):
console.log(fillet_array);
if ("undefined" !== typeof(fillet_array) && "undefined" !== typeof(fillet_array[mattes_number_layers - 2]))
{
console.log("mattes_number_layers - 2: " + (mattes_number_layers - 2)); //outputs 0
console.log("mattes_number_layers - 1: " + (mattes_number_layers - 1)); //outputs 1
console.log(fillet_array[mattes_number_layers - 2]); //outputs Object
console.log(fillet_array[mattes_number_layers - 2].index); //outputs 0
fillet_array[mattes_number_layers - 2]['index'] = (mattes_number_layers - 1);//switch index in fillet_array
}
console.log(fillet_array);
I am trying to change the index property of the object from 0 to 1, but the code I have does not seem to be working because when I output fillet_array
again, it is the same as the first one.
Edit: Here is the code creating the fillet object and adding it to the array. This is called before the code above.
var fillet = {};
fillet.index = index;
fillet.imgsrc = thumb;
fillet.width = width;
fillet.cid = cid;
fillet.sku = sku;
if (typeof(fillet_array) === "undefined")
{
fillet_array = [];
}
fillet_array[index] = fillet; //For now index is 0