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

304
Vistas
Randomizing elements in an array in Typescript giving error: TypeError: 0 is read-only

I have an array of objects, and I'd like to randomize the order of the elements.

So I have the following:

const animals  = data?.fetchAllAnimals;
let randomizeAnimals = animals.sort(()=> Math.random() -0.5 )

But I keep getting this error in firefox: TypeError: 0 is read-only

and a different error in chrome: TypeError: Cannot assign to read only property '0' of object '[object Array]'

What am I doing wrong here?

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