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

76
Vistas
JavaScript AND / OR Operand

The priority of AND && is higher than OR ||. That's why it works before OR.

In the example below, 1 && 0 is calculated first.

alert( 5 || 1 && 0 ); // 5

I don't understand how this happens?

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

0

The left-hand side will be evaluated first. Please see example

a || (b * c);  // evaluate `a` first, then produce `a` if `a` is "truthy"
a && (b < c);  // evaluate `a` first, then produce `a` if `a` is "falsy"
a ?? (b || c); // evaluate `a` first, then produce `a` if `a` is not `null` and not `undefined`
a?.b.c;        // evaluate `a` first, then produce `undefined` if `a` is `null` or `undefined`

Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence

about 4 years ago · Juan Pablo Isaza Denunciar

0

Please check Operator Precedence for more details.

Order is from left to right, when any of the early left part evaluates to be true, the rest of right side is not evaluated and is omitted.

console.log(5 || false); // 5
console.log(true || 5 || false); // true
console.log(false || 5 || 10); // 5
console.log(false || 10 || 5); // 10

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