我正在学习一些节点核心模块,我已经写了一个小的命令行工具来测试出readline
模块,但在我的console.log()
输出,我也recieving undefined
下它:/这是为什么返回'未定义?'
这里是我的代码..
var rl = require('readline');
var prompts = rl.createInterface(process.stdin, process.stdout);
prompts.question("What is your favourite Star Wars movie? ", function (movie) {
var message = '';
if (movie = 1) {
message = console.log("Really!!?!?? Episode" + movie + " ??!?!!?!?!, Jar Jar Binks was a total dick!");
} else if (movie > 3) {
message = console.log("They were great movies!");
} else {
message = console.log("Get out...");
}
console.log(message);
prompts.close();
});
这里还有什么IM在我的控制台看到..
What is your favourite Star Wars movie? 1
Really!!?!?? Episode1 ??!?!!?!?!, Jar Jar Binks was a total dick!
undefined
为什么我找回undefined
?
你认为它是什么? – JJJ 2013-02-17 11:37:45