Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

304
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda