我正在學習一些節點核心模塊,我已經寫了一個小的命令行工具來測試出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