From the course: Advanced Node.js

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Sequential execution

Sequential execution - Node.js Tutorial

From the course: Advanced Node.js

Start my 1-month free trial

Sequential execution

- [Instructor] In the first lesson, we introduced sequential execution with callbacks and we saw how nesting too many callbacks can create an anti-pattern called callback hell or the pyramid of doom. Let's take a deeper look at this anti-pattern. So inside of our example file, inside of chapter one, chapter one lesson five, the index.js has this huge pyramid of doom. So what's going on here is we're using a couple resources. We're using the file system. We're gonna write and delete the file. And then on line two, we are actually setting up a function that will cause the computer to beep. So if we write the standard output, this \xO7 code, that will actually cause the MacOS to beep, so we will hear a beep when we run this. Now this doStuffSequentially is one function, but this function has a lotta callbacks. So on line five we see that the function is starting, that's the first step. And then on line six, we're gonna set a timeout. We can't see how long that timeout is all the way down…

Contents