Intervals can be defined with the setInterval function. An interval is similar to a timeout in that a function is called after a delay. However, an interval invokes the handler continuously until it is cleared. In this video, learn how to complete the delay app by using an interval to report how long you have waited as a percentage.
- [Instructor] So far we've created a small … application that uses the set time out function … to create a three-second delay. … We can improve this application by using … the set interval function to run an interval … that intermittently reports on how long we've waited. … So in order to get this started I'm going to come up … here to line one of our timers dot JS file … and I'm going to go ahead and add a wait interval. … The wait interval will be half a second … so 500 milliseconds. … I'm also going to create a variable for the current time. … And current time will equal zero. … Most of the variables that I declare, I declare … with const because I don't want users to be able … to change their value. … However, any time I want to change the value … of a variable I'll have to declare that variable with let. … So the other thing that we're going to do … is we are going to create another function here. … Now, I'll declare the increment time function … with an arrow function but because we have …
- 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.