从用户Javascript获取int
编辑>>读线不工作,在终端“ReferenceError:未定义读线”中获取此消息 Javascript noob在这里 我正在写一个程序,试图从用户那里得到一个int。我知道如何在HTML文档中执行此操作,但是在linux机器终端上运行的.js文件中没有任何内容 比如我想说从用户Javascript获取int,javascript,linux,node.js,input,terminal,Javascript,Linux,Node.js,Input,Terminal,编辑>>读线不工作,在终端“ReferenceError:未定义读线”中获取此消息 Javascript noob在这里 我正在写一个程序,试图从用户那里得到一个int。我知道如何在HTML文档中执行此操作,但是在linux机器终端上运行的.js文件中没有任何内容 比如我想说 console.log("enter your number"); //code that collects the int named var yourint console.log ("your number was
console.log("enter your number");
//code that collects the int named var yourint
console.log ("your number was " + yourint);
它真的在折磨我的大脑,因为我知道我只是在画一个空白,解决方案是显而易见的。console.log是将消息输出到网络控制台,而不是外壳 如果您在linux中使用js24,它将抛出如下错误
typein:1:0 ReferenceError: console is not defined
您可能需要使用print
范例
var input=readline('enter your number');
print('your number was '+input)
例如var yourint=readline()?readline()不起作用了你有没有看过用于JS shell的任何程序的文档?使用node.JS是的,我只是不明白为什么它不起作用它不会抛出任何错误,它使用console.log打印。错误出现在readline()中,我无法解释原因。您使用的是什么shell interpeter?js24?