This might seem similar to some questions, but I don't have the same problems as those posters, so I don't think this is a duplicate.
if(inputSize instanceof NeuralNet){
console.log('NN being copied');
console.log(inputSize);
console.log('Copying neural net...');
this.layerA = [];
for(let i = 0; i < inputSize.layerA.length; i++)
this.layerA[i] = inputSize.layerA[i].slice();
this.layerB = [];
for(let i = 0; i < inputSize.layerB.length; i++)
this.layerB[i] = inputSize.layerB[i].slice();
console.log(this.layerA);
console.log(this.layerB);
console.log(this);
console.log('Finished copying NN');
this.biasA = inputSize.biasA;
this.biasB = inputSize.biasB;
console.log(this.layerA);
this.fitness = 0;
console.log(this);
}
This is the part of my code that has issues. I have valid values in the arrays of this.layerA and this.layerB when I apply console.log on them, so I know that there isn't an issue of me logging the arrays before they are populated with values.
However, when I log "this", I get weird values for layerA and layerB. The arrays still have the right dimensions, but most of the values within them are undefined, with a few numerical values (sometimes, not in this case).
Moreover, when I log this.layerA and this.layerB right after logging this, they still have the correct values. I have absolutely no idea why this is the case. I appreciate any help I can get. Thank you!