简体   繁体   中英

node.js console - What is `undefined` in node console?

I'm novice in javascript. My knowlegde in scripting languages is python, and we know that it use modules for specific task. In any python console, we can use

import numpy as np

But it do not return anything in the console. So if i use the "same" thing in a node console i get this

var module = require('module')
undefined

So, i'm wondering what mean that undefined return from node console.

It's the return value from declaring a variable with var . Since it doesn't return anything, you get undefined . The assignment itself does however return the right-hand-side value, so chaining assignments is possible.

undefined表示表达式没有返回值。

Every command in node returns undefined unless you tell it to return something else. It won't affect anything your program, it is just the default return statement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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