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

144
Views
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 answers
Answer question

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 Report
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!