Table of contents
No headings in the article.
You must have seen this kind of behavior when you enter console.log() in a browser console window
console.log("Hola!")
Hola!
undefined
We got two values here:
Hola!
undefined
Even though we expected the first value, the second value came as a surprise.
This is because console.log() function outputs the value of a parameter you pass to it, but it also returns 'undefined' to indicate that the function itself does not have a return value. Therefore, when you use console.log() to output a variable or an expression, the console will display the value of the variable or expression, then print 'undefined' on a new line to indicate that console.log() did not return any value itself.