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

288
Vistas
Can you explain why logical && in JavaScript returns the last operand in a statement if all operands are true, as opposed to returning boolean true

I am reading a really nice blog on logical and (&&) in javascript. javascript-and-or-logical-operators/

How logical and works

Starting from left and moving to the right, return the first operand that is falsy. If no falsy operand was found, return the latest operand.

his example

FALSY:

3 && 1 && 0 && 10; // => 0

I see that it returns 0, based on his explanation above. But why is that? Why isn't false returned instead. I realize that 0 is "falsy", so I would believe that the statement would now evaluate to boolean false? But I am not right, can you explain why?

he also presents this example

TRUTHY

true && 1 && { name: 'John' } => { name: 'John' }

I am confused again. Why does this statement return { name: 'John' } instead of returning true?

Thank you kind people for your patience in answering my question.

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