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

324
Vistas
how is [1,2,3]==[1,2,3] false in javascript?

how is [1,2,3]==[1,2,3] and [1,2,3]===[1,2,3] false? Would appreciate a simple explanation. Came across this while watching a youtube video.. anymore "anomalies" like this?

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

The == operator checks whether the two operands reference the same object. While the two objects (arrays are objects) may have the same content, they are different instances, and thus the expression is false.

about 4 years ago · Juan Pablo Isaza Denunciar

0

The === and == operators compares arrays by reference (i.e. location in memory), the easy way to think about it is that "they are different arrays with the same values".

If you give you arrays a name, maybe the reason for this will be clearer:

const arr1 = [1, 2, 3];
const arr2 = [1, 2, 3];

console.log(arr1 === arr2);

And arr1 is not the same array as arr2.

Conversely, this will log true, because it compares the same reference:

const arr = [1, 2, 3];

console.log(arr === arr);
about 4 years ago · Juan Pablo Isaza Denunciar

0

They are not equal because they are not the "same". In js, if you do [1,2,3] it stores the array as a variable with no name. Give it a name, say 'r', and do r==r and it will return true because window.r is the same as window.r. But window.undefinedvariable0 is not the same as window.undefinedvariable1, although they are visually the same.

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