Important things of Node.js to know - Part 1

We are going to see important things of Node.js. I will be posting 2 posts regarding it. Stay tuned!

If you prefer video explanation then you can watch on YouTube.

Courtesy: https://commons.wikimedia.org/wiki/File:Node.js_logo.svg


What happens
when we use 0 in setTimeout then will callback function execute immediately or not. 

It will execute after call stack is empty. Let's try that with an example.

    console.log(1);

    setTimeout(() => console.log(2), 0);

    console.log(3);

    Output:
        1
        3
        2

Are function declarations hoisted and function expression not. Before answering, we need to know what is function declarations and function expression.

    // function declaration
    function doStuff() {};

    // function expression
    const doStuff = () => {};

So, function expression is not hoisted whereas function declarations are.

For which application where Node.js is perfect to use, i.e. 

  • Data intensive real-time applications
  • I/O bound applications
  • Data streaming applications

Which are timing features in Node.js

  • setTimeout
  • setInterval
  • setImmediate

What you think "Is creating function declaration way the function are not initialised at compile time and are not available anywhere in your file". 

This statement is incorrect. So, it is initialised at compile time.

Which method of fs module used to remove directory. 

fs.rmdir() is the method to remove directory.

Which module is required to create a child process.

child_process is the module to create child process.

Which access modifiers is not supported by Typescript

default access modifier is not supported.

Are functions first-class objects.

Functions are first-class objects, because they can have properties and methods like any object. Functions can be called, but not objects.

Brief about readable stream.

  • Readable stream is used for read operation.
  • Output of readable stream can be input to a writable stream.

Comments

Popular Posts