简体   繁体   English

node.js console.log抛出了我未定义的内容

[英]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. 当我尝试在控制台中运行此代码时,我将undefined为输出。 Even the below statement while executing throws me undefined. 执行时,即使是下面的语句也会引发我的定义。

 console.log("Hello World"); 

Output 产量

 Hello World
 Undefined

Are we going to create our own server and write code with node.js? 我们要创建自己的服务器并使用node.js编写代码吗?

The last undefined is result returned from console.log method: 最后一个undefined是从console.log方法返回的结果:

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

As you can see, first 'hey' printed by console.log, but console.log returns undefined as result of operation, and it printed to output. 正如您所看到的,首先由console.log打印'hey',但是console.log作为操作结果返回undefined,并打印到输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM