I am having issue with Object.keys(arrayOfFigures[i]) returning empty array. Despite I am seeing in the debbuger that arrayOfFigures[i] is an instance of a class and has all properties and values for the specific class.
Basically I have a classes for Geometric figures that store the properties and functions for each figure type.
I also have class for reading user input and rendering the Geometric figures on canvas. The issue is with a function in the rendering class where I need all properties of a rendered instance of Geometric Figure to be displayed in a separate div on the index.html page.
I also tried to use (for in) loop but with no result. Also I suspected the issue might be I am using WeakMaps to hide the properties, so I decided to try to implement a function not in the class that is rendering the Geometry, but in the Geometric Figure class itself - same result. I feel I am missing something very basic for JS behavior of classes and enumerables and need to solve it before moving on to the next chapter...
Below are the classes for Geometric Figures (I have many more but all are descendants of class Shape and have the same functions(although functions have different implementation))
Classes for geometric figures:
This is the class for Geometry rendering:
This is the function I have issues with
initializeAllFigures(){
let infoDiv=document.getElementById('information')
infoDiv.innerHTML=''
infoDiv.innerText='Figures drawn:'
for (let i in this.arrayOfFigures){
let logParagraph = document.createElement('p');
logParagraph.setAttribute("id", i);
let arrayOfKeys=Object.keys(this.arrayOfFigures[i]);
for (let j in arrayOfKeys){
logParagraph.innerText+=`${arrayOfKeys[j]}: `
}
infoDiv.appendChild(logParagraph)
}
if (this.selectedFigure>=0){
let domElement=document.getElementById(this.selectedFigure);
domElement.style.color = '#ff0000'
}
}
This is the repository with the whole API