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

269
Views
Cannot read properties of null (reading 'getContext')

I get this error message:

"Cannot read properties of null (reading 'getContext')".

Why?

let canvas = document.getElementById("gameSecreen");
let ctx = canvas.getContext("2d");
ctx.fillRect(20, 20, 100, 100);
#gameScreen {
   border: 1px solid black;
}
<canvas id="gameScreen" width="800" height="600"> </canvas>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The error is pretty self explanatory. "Cannot read propery getContext of null" means the object on which you're calling the function getContext is null

let canvas = document.getElementById("gameSecreen"); here canvas is null because in your HTML the id of the canvas is greenScreen but you used "greenSecreen" inside getElementById.

let canvas = document.getElementById("gameScreen");
let ctx = canvas.getContext("2d");
ctx.fillRect(20, 20, 100, 100);
#gameScreen {
   border: 1px solid black;
}
<canvas id="gameScreen" width="800" height="600"> </canvas>

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!