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.
node also prints undefined because IN GENERAL, it displays the return value of each command and console. log doesn't return anything. Show activity on this post. this is happening because console.
This is because console. log() does not return a value (i.e. returns undefined). The result of whatever you entered to the console is first printed to the console, then a bit later the message from console. log reaches the console and is printed as well.
The undefined property indicates that a variable has not been assigned a value, or not declared at all.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With