The standard input object allows you to send data to your process while it is running. In this video, learn how to listen for user input from the terminal using standard input. Also, discover how to complete the question and answer app by displaying the answers back to the user just before the process quits.
- [Instructor] In the last lesson, we built … the first part of the question answer app, … which defines the questions as long … as they function to ask or prompt the user for each answer. … So in this lesson, we're going to use … the process.standardinput object to listen for answers. … So I'm going to continue working in the same file. … The first thing I'm going to do down here … is wire up a listener using process standard input, … and we're going to use the on function to listen for events. … The event name that we're listening for is a data event. … That means that you've typed something … into the keyboard and you've pressed enter. … In the second argument of the on function … is the handler or the function that … we will use to handle that data. … So I can collect your data as the … first argument that's sent back … to this callback function and do something with it. … For right now, we'll just echo it back to … the user using process standout write, … and we'll write a couple new lines, …
- What is Node.js?
- Installing Node.js
- The global object
- Importing the core modules
- Creating custom events with the EventEmitter
- Reading, writing, and removing files
- Working with file streams
- Creating child processes with the exec and spawn functions
Skill Level Intermediate
Node.js: Real-Time Web with Socket.IOwith Emmanuel Henri1h 24m Intermediate
1. What Is Node.js?
2. Set Up Your Environnment
3. Node Globals
4. Node Modules
5. File System Basics
6. Files and Streams
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.