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

173
Vistas
Array.sort() method change my object before it called, mutability issue?

I think there is a notion that I do not understand well, namely the notion of mutability.

Here is my code:

console.log(inputs); // Already sorted (?!)
// sort the array
inputs.sort(function(a, b) {
    return a.order - b.order;
});

Only thing is, my console.log shows me the array inputs already sorted, while the .sort() method only applies afterwards.

I think it's a mutability problem, I just don't quite understand the scope of it. Why my console.log print the array already sorted ?

Thanks in advance

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