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

141
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

try

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

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

about 4 years ago · Juan Pablo Isaza Denunciar

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 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