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

177
Vistas
How to get rid of the undefined message on Chrome?

How to get rid of the undefined message after console.log() a variable

var example = 5;
console.log(example);

output: 5
undefined

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

0

You can't:

The reason the debug console outputs undefined after a function, is because you're running the function (example()) and then in the function body, there is no return statement so by default, the return statement will return undefined.

More about return statements at MDN

The reason it does, is: say you have a function called example

function example() {
  // Code here
}

Using the return statement inside the function, will return something:

function example() {
  // Code here
  return "Some string";
}

By default (with no return statement) there will be an undefined return statement.

function example() {
  // Code here
}

example(); // undefined
function example() {
  // Code here
  return true;
}

example(); // true

Also, it does not happen only on Chrome. It happens on all modern and old browsers with JavaScript enabled.

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