Is there a way to read standard input with JavaScript?

后端 未结 5 613
名媛妹妹
名媛妹妹 2020-12-08 20:09

I saw this for lots of other languages but not JavaScript.

I\'m trying to do problems like: this (codechef.com) and of course the programs need to be able to read

5条回答
  •  悲哀的现实
    2020-12-08 20:30

    It depends on the environment that your JavaScript is executing in.

    In the browser, there is no standard input (the browser isn't a console). The input would come generally from some textbox element in a form on the page.

    If you're using something like Rhino, then you can import the standard Java I/O classes and read from stdin that way (see the second example no longer on the wiki).

提交回复
热议问题