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

145
Vistas
Reason for "Cannot read properties of undefined"

Here's the thing. I looked up a pong game for java and now I want to try to make it in js. I'm still not good at js and I'm trying to code a simple pong game while trying to use classes like in java. But the problem is I always get this error "Uncaught TypeError: Cannot read properties of undefined (reading 'move')". I've tried looking online for solutions but I still don't get it. This also shows up for the other two methods, draw and run. Can anyone please kindly tell me why this happens?

class Game {
    constructor() {
        this.run();
    }
    run() {
        this.move();
        this.draw(ctx);
        requestAnimationFrame(this.run);
    }
    draw(ctx) {
        paddle.draw(ctx);
    }
    move() {
        paddle.move();
    }
}

let game = new Game();

Thank you very much in advance to anyone who will answer this.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

In this case, you call to the method of instancepaddle and it's not declare yet. That's why, javascript cheat as paddle undefine variable.

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