I am complete new to open source and would really like to use it more. I installed (x86)node.js from nodejs.org. I launched "Node.js command prompt" from the installed list, and executed node.exe. I am trying to to run some sample javascript. Why is it if I do:
>var life = 11;
undefined
^^^^^^^^^
why am I getting this message?
or
>a = [1,2,3]
[1,2,3]
>a.forEach(function (v) {console.log(v);});
1
2
3
undefined
^^^^^^^^^
//still get this, even though the script executed??
>
undefined
is just the return value of the statements you executed. Only meaningful/useful if you've executed a function, really.
The console prints the return value of your script, which is undefined
Write this:
"hello";
And press enter. Now the return value should be "hello"
and not undefined
.
You could also do;
var life = 11; life;