I create an object with two properties. Each property is a two dimensional array of strings. Below you can see how the arrays are filled and saved as properties.
let dataCodewords=["00100000", "01011011", "00001011", "01111000", "11010001", "01110010", "11011100", "01001101", "01000011", "01000000", "11101100", "00010001", "11101100", "00010001", "11101100", "00010001"];
let dataCodewordGroups={};
let position=0;
// blocksCodewords.group1Blocks[version-1] is 16 in this case
let group1=[];
for(let j=0; j<blocksCodewords.group1Blocks[version-1]; j++){
let block=[];
// blocksCodewords.blocks1codewords[version-1] is 1 in this case
for(let k=0; k<blocksCodewords.blocks1codewords[version-1]; k++){
block.push(dataCodewords[position]);
position++;
}
group1.push(block);
}
dataCodewordGroups.group1=group1;
// blocksCodewords.group2Blocks[version-1] is 0 in this case
let group2=[];
for(let j=0; j<blocksCodewords.group2Blocks[version-1]; j++){
let block=[];
// blocksCodewords.blocks2codewords[version-1] is 0 in this case
for(let k=0; k<blocksCodewords.blocks2codewords[version-1]; k++){
block.push(dataCodewords[position]);
position++;
}
group2.push(block);
}
dataCodewordGroups.group2=group2;
When logging the properties, the result is as I expected:
console.log(dataCodewordGroups.group1);
// >> ["00100000", "01011011", "00001011", "01111000", "11010001", "01110010", "11011100", "01001101", "01000011", "01000000", "11101100", "00010001", "11101100", "00010001", "11101100", "00010001"]
But logging the object changes the type of the stored data:
console.log(dataCodewordGroups);
// >> {[32, 91, 11, 120, 209, 114, 220, 77, 67, 64, 236, 17, 236, 17, 236, 17][]}
Why are the strings converted to numbers?