Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

303
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda