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

101
Vistas
Unexpected assignment within ConditionalExpression

I am trying to update a lib I got from GitHub and there is a strange condition I have never seen before, can someone help me understand what is this? As I understand _c = _b === null means that _c get's a value of true or false... and later on _c !== undefined will always be true.. am I missing something?

  const _b = { isWrappable: true, insertedTag: false };
  let _c;
  const status = (_c = _b === null || _b === undefined ? undefined : _b.isWrappable) !== null && _c !== undefined ? _c : false;
  console.log(status);

after this line status is true

Now, how can I change this line to avoid Unexpected assignment within ConditionalExpression. because everything I tried gives me false, for example:

  const _b = { isWrappable: true, insertedTag: false };
  const _c = _b === null;
  const test = (_c || _b === undefined ? undefined : _b.isWrappable) !== null && _c !== undefined ? _c : false;
  console.log(test);

  • _b is a variable, it can be null or undefined sometimes

Thanks

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

0

I've solved it :) in my research I found Nullish coalescing operator (??) and solved my problem So the answer is

const _b = {
  isWrappable: true,
  insertedTag: false
};
const status = _b?.isWrappable ?? false;
console.log(status);

The optional chaining operator and Nullish coalescing operator solved that mess.

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