Class 8

Amanda Rush
2 min readSep 19, 2021

1. What is “callback hell” and how can it be avoided?

Callback hell is when you have several nested callbacks which form a pyramid structure that is difficult to understand and maintain. If there is an error in one of the functions, all of the other functions are affected. To avoid callback hell, you should separate your functions at the top level instead of nesting them. You can also use promises to chain calls.

2. What are “stubs” in Node.js?

Subs are used to create fake endpoints so that you can test your code without it breaking. It may be that you are planning to write that code later but you need to test something else. Or if someone else will be writing the code it creates a placeholder for it. The stub usually returns a fixed response that could be a realistic result from the code once it is written.

3. What are “streams” in Node.JS?

Streams are used to process large amounts of data over time using smaller chunks at a time. This allows the data to start processing right away instead of waiting for it to completely upload/download before starting.

4. What does “chaining” mean in Node.JS?

Chaining allows you to chain together multiple asynchronous tasks in a specific order. When a callback function returns a promise, you can chain on another then call which will run when the second promise is fulfilled.

5. Explain “console” in Node.JS.

The console in Node.js is a global object that allows you to display various messages. The console class messages are console.log, console.error and console.warn. It can be used for debugging.

6. Explain exit codes in Node.JS. List out some exit codes.

Exit codes are used to end a process in Node.js. Some examples of exit codes are Fatal Error, Invalid Argument, and Uncaught Fatal Exception.

7. What is the difference between cluster and non-cluster Index?

Each table can only have one clustered index, but a single table can have multiple non-clustered Indexes. Custard indexes only sort tables so they don’t use extra space. Non-clustered indexes are stored separately so they do use extra storage space. Clustered indexes are faster because they don’t require extra lookup steps.

8. What are user defined functions? What are all types of user defined functions?

A user defined function is code that extends the functionality of MySQL by adding a function that acts like a native function in MySQL. The types of user defined functions are scalar functions, table-valued functions and system functions.

--

--