Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!