node.js displays "undefined" on the console


Recently I installed node.js on my Windows 7 machine.

On execution of JavaScript, I get an undefined message along with successful execution of the expression.

What's wrong here? I have not noticed any other side effects.

enter image description here

4/17/2012 7:22:34 AM

Accepted Answer

Just write "hello world"; and hit enter... it will return "hello world" instead of undefined, thus no undefined is displayed. console.log returns undefined and also logs arguments to console so you get multiple messages.

12/10/2011 3:20:36 PM

The JavaScript functions always return something. If you don't specify something to return in the function, 'undefined' is returned by default (you can check this out in Firebug too).

Don't worry though, this doesn't affect anything, you can ignore it.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow