Nodejs display undefined on console even when function has return value

I was just playing with node and I noticed even when I specify a return value for my function node still returns undefined.

screenshot

Whats wrong here? reading previous post related to my question, I am under the impression that if you specify a return type node shouldn't display undefined

It doesn't return undefined, it clearly returns 5. The function declaration returns undefined (mainly because of (a) how eval() works and (b) because functions with no return values technically return undefined per the standard), but when you make a call to the function itself, e.g. x(), you get back a 5.

You'll notice that variable declarations in the global scope, like var test = 1, also will immediately return an undefined in the console. This does not mean that test is now undefined.