User Input in Javascript

Like we have input() function in python, std::cin in c++, do we have some built in function in javascript or any of its module or libraries to get user input from the terminal?

Yes. There is actually a NodeJS module called readline

3 Likes

Yeah, generally readline is used for the basic command line input. If you’re trying to do something more robust, I prefer inquirer, but it’s a little heavy-handed if you just want to get one or two inputs from the user.

Check out the Node docs on accepting input from the command line for more info on both readline and inquirer

3 Likes