Category: Node JS Interview Question

https://cdn3d.iconscout.com/3d/premium/thumb/interview-question-3d-icon-download-in-png-blend-fbx-gltf-file-formats–interviewer-hr-manager-pack-business-icons-9684875.png

  • What is REPL in Node.js?

    REPL stands for Read Eval Print Loop, and it represents a computer environment. It’s similar to a Windows console or Unix/Linux shell in which a command is entered. Then, the system responds with an output

    repl2
  • What is a callback function in Node.js?

    A callback is a function called after a given task. This prevents any blocking and enables other code to run in the meantime.

    In the last section, we will now cover some of the advanced-level Node.js interview questions.

  • How do we implement async in Node.js?

    As shown below, the async code asks the JavaScript engine running the code to wait for the request.get() function to complete before moving on to the next line for execution.

    async
  • How do you create a simple server in Node.js that returns Hello World?

    simple-server
    • Import the HTTP module
    • Use createServer function with a callback function using request and response as parameters.
    • Type “hello world.” 
    • Set the server to listen to port 8080 and assign an IP address
  • Explain asynchronous and non-blocking APIs in Node.js.

    • All Node.js library APIs are asynchronous, which means they are also non-blocking
    • A Node.js-based server never waits for an API to return data. Instead, it moves to the next API after calling it, and a notification mechanism from a Node.js event responds to the server for the previous API call
  • How do you create a simple Express.js application?

    • The request object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on
    • The response object represents the HTTP response that an Express app sends when it receives an HTTP request
  • What are streams in Node.js?

    Streams are objects that enable you to read data or write data continuously.

    There are four types of streams:

    Readable – Used for reading operations

    Writable − Used for write operations

    Duplex − Can be used for both reading and write operations

    Transform − A type of duplex stream where the output is computed based on input

  • What is the Express.js package?

    Express is a flexible Node.js web application framework that provides a wide set of features to develop both web and mobile applications

  • What is the package.json file?

    The package.json file is the heart of a Node.js system. This file holds the metadata for a particular project. The package.json file is found in the root directory of any Node application or module

    This is what a package.json file looks like immediately after creating a Node.js project using the command: npm init

    You can edit the parameters when you create a Node.js project.

    node-npm
  • How would you use a URL module in Node.js?

    The URL module in Node.js provides various utilities for URL resolution and parsing. It is a built-in module that helps split up the web address into a readable format.

    varurl