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

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

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