Sunday, February 2, 2020

BlogPost_304

  • What is “callback hell” and how can it be avoided?
    • Also known as the pyramid of doom. If you make callback after callback it can get out of hand. 
    • The solution is to design around it. Use modules. Give your functions names. Declare your functions beforehand. Take some times to think about the structure of your code. 
  • What are ‘stubs’ in Node.js?
    • Test stubs are functions (spies) with pre-programmed behavior. They support the full test spy API in addition to methods which can be used to alter the stub's behavior. As spies, stubs can be either anonymous, or wrap existing functions.
  • What are “Streams” in Node.JS?
    • Streams are unix pipes that let you easily read data from a source and pipe it to a destination. Simply put, a stream is nothing but an EventEmitter and implements some specials methods. Depending on the methods implemented, a stream becomes Readable, Writable, or Duplex (both readable and writable).
  • What you mean by chaining in Node.JS?
    • If you meant Method Chaining, it is nothing but a syntactic sugar commonly seen in Object Oriented Languages. In chaining every method return the object, so that we can chain different calls in single line. See the below example for better understanding.
  • Explain “Console” in Node.JS?
    • The console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.
      The module exports two specific components:
      • Console class with methods such as console.log()console.error() and console.warn() that can be used to write to any Node.js stream.
      • A global console instance configured to write to process.stdout and process.stderr. The global console can be used without calling require('console').
  • Explain exit codes in Node.JS? List out some exit codes?
    • exit() takes an exit code (Integer) as a parameter. The code 0 is the default and this means it exit with a 'success'. While the code 1 means it exit with a 'failure'. You may use process.
  • What is the difference between Cluster and Non-Cluster Index?
    • Cluster index is a type of index that sorts the data rows in the table on their key values whereas the Non-clustered index stores the data at one location and indices at another location.
  • What are user defined function? What are all types of user defined functions?
    • There can be 4 different types of user-defined functions, they are: Function with no arguments and no return value. Function with no arguments and a return value. Function with arguments and no return value. Function with arguments and a return value.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home