>Undefined

>Undefined

Understanding undefined in browser console.

When using the console.log() in the browser console, we all have noticed that an "undefined" line appears after the log message.

console.log("Hello, world!");
Hello, world!  
undefined

This "undefined" is normal and it appears due to the way JavaScript function works. JavaScript function always returns a value, if a function doesn't return anything, it will return undefined by default. This is also true for the console.log() function. So when we execute a console.log() function in the console, the statement will output the message we have passed, but the function doesn't return any value, the console will display "undefined" on the next line, which is the default return value.

Conclusion

The undefined output in the browser console after using the console.log() is a normal part of the console's behavior and there is nothing to worry about.