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

153
Vistas
Uncaught TypeError: Cannot set properties of undefined in Javascript module

The following javascript module add a simple div into html file. When I called board.drawIn(), everything works well. But when I called board.initIn(), I got,

gomoku.js:3 Uncaught TypeError: Cannot set properties of undefined (setting 'board')

I'm quite confused because initIn() function actually does nothing but call drawIn() directally. Anyone can help?

const board = (() => {
    function drawIn(container) {
        this.board = document.createElement('div');
        this.board.classList.add('gomokuBoard');
        container.appendChild(this.board);
    }

    function initIn(container) {
        drawIn(container);
    }

    return { drawIn, initIn };

})();

const gomoku = (() => {
    function initIn(container) {
        //board.drawIn(container);    /* this works */
        board.initIn(container);      /* doesn't work */
    }

    return { initIn };
})();

gomoku.initIn(document.querySelector('body'));
.gomokuBoard {
    width: 100px;
    height: 100px;
    border: 1px solid black;
}

about 4 years ago · Juan Pablo Isaza
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