Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

102
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda