All tied together class 8

Ramon Cruz-Hinojosa
2 min readJul 24, 2021
  • What is “callback hell” and how can it be avoided?

Call back hell is what happens when a developer tries to write code as if it should execute from top to bottom of the page. This ends up causing large blocks of functions that are a ton of nested if else statements or functions within functions all trying to do everything at once. The best way to avoid making this mistake is to always name your functions something easy to understand. Another way to avoid callback hell is to modularize, or put functions into another file and export them into your main file to keep things clean and easy to read.

  • What are “stubs” in Node.js?

A small program routine that substitutes for a longer program which is possible to be loaded later or that is remotely located. Is used to replace large functions for testing.

  • What are “streams” in Node.JS?

A node stream is a way to transfer bigger amounts of data by breaking the data down in smaller more manageable chunks.

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

Chaining is the practice of splitting more complex functions into smaller more focused functions that pass their results to the next function to keep things easy to understand.

  • Explain “console” in Node.JS.

The console in Node.JS is a global object that is used to print different levels of messages for the developer to see. For me the console is where I’m able to post messages for myself to test my code.

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

Exit codes are used to end a process. There are codes that can be used to fit whichever situation you might need them. An example of a few are: Uncaught Fatal Exception — There was an uncaught exception, and it was not handled by a domain or an uncaughtException event handler.

Fatal Error — There was a fatal unrecoverable error in V8. Typically a message will be printed to stderr with the prefix FATAL

Invalid Argument — Either an unknown option was specified, or an option requiring a value was provided without a value.

  • What is the difference between cluster and non-cluster Index?

There is more than just one difference between clustered and non clustered indexes but the main takeaway I’m getting from the differences is that clustered index is faster, requires less memory for operations and the way data is stored is easier to understand.

  • What are user defined functions? What are all types of user defined functions?

User defined functions are routines that accept parameters, perform an action, such as a complex calculation, and return the result of that action as a value. There are 4 types of user defined functions:

  1. Function with no arguments and no return value
  2. Function with no arguments and a return value
  3. Function with arguments and no return value
  4. Function with arguments and a return value

--

--