Node.js console.log throws me undefined

 var sys = require("util");

      

When I try to run this code in the console, I get undefined

as output. Even the below expression is throwing undefined for me at runtime.

 console.log("Hello World"); 

      

Output

 Hello World
 Undefined

      

Are we going to build our own server and write code with node.js?

+3


source to share


1 answer


The latter undefined

is the result returned by the console.log method:

node
> console.log('hey')
hey
undefined
> 

      



As you can see, at first "hey" is printed console.log, but console.log returns undefined as a result of the operation and is printed to output.

+7


source







All Articles