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

114
Vistas
Why does an undefined operand not return false?

Given the following:

let a;
let b = false;
let c = a && b === undefined;

In my understanding, undefined is a falsy value, so why is it that c has value undefined instead of false?

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

0

c ends up undefined because a is undefined. The && operator stops with the first value that's falsy through a process called short circuiting

about 4 years ago · Juan Pablo Isaza Denunciar

0

Given your example, a is undefined. Therefore, a && ... is undefined && ..., and since undefined is falsy, the left hand side short circuits. That means, it never evaluates the right hand side.

If the left hand side is falsy, there's nothing the right-hand side of an && can do to change that. To use an analogy, false && anything always evaluates to false, and in JavaScript, it stops there and ignores anything.

Now, the question may be, "Why doesn't it return false instead of undefined?" MDN says:

The logical AND operator, &&

If the first object is falsy, it returns that object

false && "dog" // ↪ false

0 && "dog" // ↪ 0
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