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

280
Vistas
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 Respuestas
Responde la pregunta

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