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

207
Vistas
JavaScript Cannot Set Property '0' of undefined (2-dimensional array)

I know a bunch of people have already asked this, but nothing I have tried has worked. I have been stuck for days.

I suspect it may just be because the thing I am using (code.org) is a pile of flaming garbage, and it uses ES5. If you notice anything wrong, though, please let me know!

function Vector2(x, y)
{
  this.x = x;
  this.y = y;
  
  return this;
}

function Pixel(x, y, darkness)
{
  this.position = Vector2(x, y);
  this.darkness = darkness;
  
  this.rgbDarkness = this.darkness * 255;
  
  return this;
}

function DataTexture2D(offsetX, offsetY, width, height)
{
  this.offset = Vector2(offsetX, offsetY);
  this.size = Vector2(width, height);
  
  this.pixels = [];
  
  for (var x = 0; x < width; x++)
  {
    this.pixels[x] = [];
    for (var y = 0; y < height; y++)
    {
      this.pixels[x][y] = Pixel(x + this.offset.x, y + this.offset.y, 0.5);
    }
  }
  
  return this;
}

var test = DataTexture2D(100, 50, 200, 300);

console.log(test.offset.x);

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