How do I get console input in javascript?

前端 未结 4 2123
独厮守ぢ
独厮守ぢ 2020-12-04 17:21

I\'m currently using spidermonkey to run my JavaScript code. I\'m wondering if there\'s a function to get input from the console similar to how Python does this:

<         


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 18:05

    In plain JavaScript, simply use response = readline() after printing a prompt.

    In Node.js, you'll need to use the readline module: const readline = require('readline')

提交回复
热议问题