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

140
Visualizações
Get empty string instead of null

I have null in a row if there no number. I need to put empty string in a row instead of null.

<td>${number}</td>. // null, if there no number,

so, Am I thinking in the right way? :

!number ? number : "" 
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

This will check if the variable's type is number and if not it won't render anything:

typeof number === 'number' ? number : ''
about 4 years ago · Juan Pablo Isaza Relatório

0

try

`<td>${!number ? '' : number}</td>`

if there is no number then display '' else display number

about 4 years ago · Juan Pablo Isaza Relatório

0

You can use Nullish coalescing 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.

Working Demo :

let number = null;

document.getElementById('numberText').innerHTML = number ?? ''
<p id="numberText"></p>

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