Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

299
Views
Issue with Object.keys()

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:

pastebin.com/vsV4KbmR

This is the class for Geometry rendering:

https://pastebin.com/nkj60uyx

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'
    }

}

https://pastebin.com/NiV4EcbB

This is the repository with the whole API

https://github.com/nikolaydimov83/Javascript_OOP_Homeworks

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!