I have a really odd issue. I’m trying to create a array keyed from the keys of another object. Here is the sample code:
const testObj = {
something: {
test: '1',
}
}
const some_array = [];
// Create an array that looks like this: some_array['test'] = '1';
for (const object in testObj) {
for (const object_key in testObj[object]) {
some_array[object_key] = '1';
}
}
console.log(some_array);
Console output of array
This creates the array as expected with the right key and item but the array shows as length: 0 and I can’t iterate over it. Any looping method I try on it never executes. I assume I’m doing something wrong with using the object from the loop as the key for the array. But I’m confused why the array looks fine otherwise yet the engine clearly thinks that array is empty.
2