I need to get user input when running .js in the console with spidermonkey as follows:
.js
$ js myprogram.js
What is the equivalent of JavaScript Ruby gets ?
gets
As far as I know, there is a readline () function, but this is a special function for spidermonkey, it is not part of javascript.
Example:
1) Readline-test.js:
print("Type some text and press <ENTER>:\t"); var userInput = readline(); print("User input: " + userInput);
2) js readline-test.js
For more information, see https://developer.mozilla.org/en-US/docs/SpiderMonkey/Introduction_to_the_JavaScript_shell .
You cannot depend on which console is there. This is not what is guaranteed, even if most browsers have a javascript console. In addition, I do not believe that you can get values ββwithout calling a function from the console.