nodejs console doesn't print returned value

The following snippet shows the output (3,6,9...) in both the nodejs console and a browser console:

 

var somearr = [1, 2, 3, 4, 5];
somearr.map(function(value){
return value * 3;
})

When run in Webstorm through the default nodejs configuration, it doesn't print anything. Am I missing some setting or is this working as intended?

6 comments
Comment actions Permalink

the run console only shows values printed to stdout/stderr... You don't print anything in your code, do you?

neither I can see anything in browser (Chrome) console if I run your code snippet there (by adding this script to HTML page)

0
Comment actions Permalink

I didn't, no. Seemed just weird that both the browser and standalone nodejs console both return the data for the user to see, and Webstorm does not. This forces me and other users to console.log everything when trying out new stuff in js.

0
Comment actions Permalink

As I wrote above, I can't see anything in browser console when running your code...

0
Comment actions Permalink

Chrome:

Firefox:

 

I hope you're not using IE at Jetbrains, Elena ^^ :)

 

**EDIT:

IE, too, returns the output array to the screen:

 

 

** Double Edit:

when stopped at any point in the code and clicking on debug, one can paste the code in the debugger console and will see the result of that operation, too:

 

0
Comment actions Permalink

In browser, you are using Live console - i.e. you enter your code directly in console and evaluate it there. Same functionality is available in Webstorm when debugging - you can enter your code in Debugger Console window and see the result

2
Comment actions Permalink

After trying out a few things, this absolutely makes sense. Thanks Elena for your help!

1

Please sign in to leave a comment.