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

156
Visualizações
what does ?? mean in JavaScript

I'm curious to know that what does a ?? mean in JS?

form.inputs.forEach(input => {
      stepProperties[input.field] = {
        info: input.fieldInfo,
        description: input.fieldLabel,
        default: input.fieldDefault ?? '',
        ...getInputType(input.fieldType, fieldTypes),
      };
      itemToPush.properties = stepProperties;
    });

in the above code snippet the value of default key is input.fieldDefault ?? ''

would like to understand this line.

I did google but did not get any proper answer.

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

It's the nullish coalescing operator, if the left side is null or undefined it will return the right side

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

about 4 years ago · Juan Pablo Isaza Relatório

0

?? is the "nullish coalescing operator" a special case of the "||". It returns the right side operand if the left side operand is falsy.

Source

about 4 years ago · Juan Pablo Isaza Relatório

0

The nullish coalescing operator (??) is a logical operator that returns its right-hand side operand when its left-hand side operand is null or undefined, and otherwise returns its left-hand side operand.

let input = {};
let variable = input.fieldDefault;

console.log(`variable is undefined : ${variable == undefined}`);

variable = input.fieldDefault ?? '';

console.log(`variable is undefined : ${variable == undefined}`);
console.log(`variable is empty string : ${variable == ''}`);

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