Is there a way to read standard input with JavaScript?

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).

Leave a Comment