简体   繁体   中英

SublimeREPL Node.js: returns for every line?

I'm a newb getting started with JavaScript. I've been using SublimeText 2 and I was greatly helped in the past by using SublimeREPL to get immediate feedback when i was learning Ruby.

Now that I'm working on JS, I've tried to set it up for Node. I installed Node.js on my computer, and it's working from the command line. (However, I'd strongly prefer using SublimeREPL since I can run whole saved files from the color-coded text editor.) SublimeREPL works pretty well, but I'm getting a strange 'undefined' return for every line . I'm not sure why, and I'd like it to stop.

For example, from this program:

var chhd = "cheese head"
var number = 0
while (number <= 12) {
    console.log(number);
    number = number + 2;
}
chhd.toUpperCase();

I get this result:

> undefined
> undefined
> ... ... ... 0
2
4
6
8
10
12
14
> 'CHEESE HEAD'

What's going on? Should I be getting all these 'undefined's and elipses? And if not, how can I remove them to get SublimeREPL for Node working properly?

Not sure about the ellipses, but the Node REPL behaves the same way on the 'undefined'. The return value of the line in question ( var chhd = "cheese head"; ) is in fact undefined when interpreted (insofar as it has no return value, like an equation would have (eg 1+2 ).

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