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

  • Why is Node.js preferred over other backend technologies like Java and PHP?

    Some of the reasons why Node.js is preferred include:

    • Node.js is very fast
    • Node Package Manager has over 50,000 bundles available at the developer’s disposal
    • Perfect for data-intensive, real-time web applications, as Node.js never waits for an API to return data
    • Better synchronization of code between server and client due to same code base
    • Easy for web developers to start using Node.js in their projects as it is a JavaScript library
  • What is the purpose of the module .Exports?

    In Node.js, a module encapsulates all related codes into a single unit of code that can be parsed by moving all relevant functions into a single file. You may export a module with the module and export the function, which lets it be imported into another file with a needed keyword.

  • What are the modules in Node.js?

    Modules are like JavaScript libraries that can be used in a Node.js application to include a set of functions. To include a module in a Node.js application, use the require() function with the parentheses containing the module’s name.

    Node.js has many modules to provide the basic functionality needed for a web application. Some of them include:

    Core ModulesDescription
    HTTPIncludes classes, methods, and events to create a Node.js HTTP server 
    utilIncludes utility functions useful for developers
    fsIncludes events, classes, and methods to deal with file I/O operations
    urlIncludes methods for URL parsing
    query stringIncludes methods to work with query string
    streamIncludes methods to handle streaming data
    zlibIncludes methods to compress or decompress files
  • What is NPM?

    NPM stands for Node Package Manager, responsible for managing all the packages and modules for Node.js.

    Node Package Manager provides two main functionalities:

    • Provides online repositories for node.js packages/modules, which are searchable on search.nodejs.org
    • Provides command-line utility to install Node.js packages and also manages Node.js versions and dependencies  
  • How is Node.js most frequently used?

    Node.js is widely used in the following applications:

    1. Real-time chats
    2. Internet of Things
    3. Complex SPAs (Single-Page Applications)
    4. Real-time collaboration tools
    5. Streaming applications
    6. Microservices architecture
  • Explain the difference between frontend and backend development?

    Front-endBack-end
    Frontend refers to the client-side of an applicationBackend refers to the server-side of an application
    It is the part of a web application that users can see and interact withIt constitutes everything that happens behind the scenes
    It typically includes everything that attributes to the visual aspects of a web applicationIt generally includes a web server that communicates with a database to serve requests
    HTML, CSS, JavaScript, AngularJS, and ReactJS are some of the essentials of frontend developmentJava, PHP, Python, and Node.js are some of the backend development technologies
  • How would you define the term I/O? 

    • The term I/O is used to describe any program, operation, or device that transfers data to or from a medium and to or from another medium
    • Every transfer is an output from one medium and an input into another. The medium can be a physical device, network, or files within a system
    io
  • What are the advantages of using promises instead of callbacks?

    • The control flow of asynchronous logic is more specified and structured.
    • The coupling is low.
    • We’ve built-in error handling.
    • Improved readability.
  • Explain callback in Node.js.

    A callback function is called after a given task. It allows other code to be run in the meantime and prevents any blocking.  Being an asynchronous platform, Node.js heavily relies on callback. All APIs of Node are written to support callbacks.

  • If Node.js is single-threaded, then how does it handle concurrency?

    The Multi-Threaded Request/Response Stateless Model is not followed by the Node JS Platform, and it adheres to the Single-Threaded Event Loop Model. The Node JS Processing paradigm is heavily influenced by the JavaScript Event-based model and the JavaScript callback system. As a result, Node.js can easily manage more concurrent client requests. The event loop is the processing model’s beating heart in Node.js.