Quick Contact

    Node JS Question Answers

    Q1-: Explain Node JS?
    Node JS Question Answers

    Node JS is open source platform or cross-platform which runs as back-end JavaScript runtime environment on chrome (V8 engine).

    It supports following OS, Z/OS, Linux, macOS, Microsoft Windows, open BSD, SmartOS.

    It includes C, C++, JavaScript, CoffeeScript languages. As different browsers have engines to convert script languages. So, many browsers like Netscape have spidermonkey etc. So chrome create V8 engine. V8 become most popular Javascript Engine. So, this engine makes conversion faster of JavaScript language used in chrome to machine language. So, it means that use JavaScript everywhere because V8 engine convert it faster with its component like for Mobile App, Desktop or server side. Some organizations create V8 Engine runtime environment that work on machine named as Node JS. So, node JS is not a programming language or framework, it is runtime environment where you can run JavaScript you can built. Node JS standalone application with HTTP. You can use Node JS on server side. So now using Node JS environment you can use JavaScript both on browser as well as on server side. Node JS also called NPM i.e. Node Package manager.

    Q2- Features of Node JS?

    Main features of Node JS is Productivity, Fast, Real-Time Application, asynchronous and Streaming in Node JS.

    PRODUCTIVITY-: Node.js is based on JavaScript. In this you can use same language for both Front-End and Back-End. It increases productivity of application development.

    FAST- It is very fast runtime environment. It runs on Google V8 engine that helps to compile JavaScript into machine code and makes it run fast.

    ASYNCHRONOUS- Node JS is event driven environment that you can implement asynchronous processing for user interface or users action. It helps to handle large amount of requests in short period of time. Asynchronous pattern helps to manage traffic of multiple requests.

    REAL TIME APPLICATION-: With Node JS you can easily build Real-Time Application like gaming app or chat app etc. that require real-time interaction and processing.

    STREAMING-: There are Streaming applications like watching Netflix or youtube in that also it’s very easy to Read and Write using Node JS. Websockets on Node JS helps to read/write. It makes it very suitable for streaming applications.

    Q3-: Who developed Node JS and how to use REPL in Node JS?

    Node JS was developed in 2009 by Ryan Dahl.

    First if you want to know the version of node js then write following command as- “Node –v”. REPL means Read Evaluate Print Loop. When you type something in prompt and click to execute then REPL Process the prompt and give output in prompt. REPL read the prompt, evaluate it and then print the result and show the prompt with specific loop.

    Just type node then you will enter in REPL.

    REPL make writing scripts very easy. For example-:

    Now understand ease of REPL from following different aspects-

    1. If you want to add two number then just write “1+1” and enter you got the result “2” you no need to define “a=1” etc.
    2. If you write var a; to ask for variable then output will be undefined. So you have to write-:




    And if you want to add in A then just write


    Output will be 30

    Same in other aspects all you have to do is define the values and just simple ask for the output by directly put the variable.

    You can better understand by following code-:



    >var a;








    >var b=a+3;




    >if (a>9) (

    … console.log(“a is greater than 9”);


    A is greater than 9




    If you exit REPL once then when you again go to REPL by putting node then all variable which were created will be erased.

    Q4-: REPL commands in Node JS?

    Below are some REPL main commands-:]

    1. Ctrl+c = For terminating current command
    2. Ctrl+c twice = for terminating REPL.
    3. Ctrl+d- for terminating REPL
    4. Tab keys – list of all current commands.
    5. .break – exit from multiline expression.
    6. .save with filename – save REPL session to a file.
    Q5-: Explain NPM in Node JS?

    NPM is three different things; stand for node package manager, its Idea about managing the packages. Let’s suppose the third party library like lodash. Lodash is very good library having amazing manipulation feature used for JavaScript. Usually what developer does, developer go to library and download the source and save to the project. So, JavaScript has its own package manager or library for the convenience. So, NPM has following features-:

    1. Repository/ Registry

      It has online repository managed by the company named as “npm, inc”. What they do is, they have place where all third party library developers can publish their libraries. Publisher of Lodash publish JavaScript file to npm repository.

      Another thing is when you create a project; npm is going to add one file known as “package.JSON”. Package.json contains all the dependencies. If you give the project to someone else without notify about lodash library, they take the project and check the package.json file and read all the dependencies. As they run the npm command on the project. NPM command checks the package.json file and checks the dependencies that need to get. Then they go to npm repository and download all the dependencies and make it available on the project. So, in all things many things are managing with npm as- managing libraries, managing versions and you are making sure that versions are consistent and development process is easy. So that is NPM.

    Q6-: Explain callback in Node.JS and how it can be more scalable?

    Callback is called when asynchronous operation has been completed. Callbacks are heavily use by Node.js and all API’S OF Node.js is written to support callbacks.

    How it can be more scalable?

    Node.js works well for input output bound but not CPU bound work. For instance, to read a file if there is a function then file reading will be started during that instruction and once input output is done, callback function is called.

    So, no blocking will be there with callbacks.

    Q8-: Explain global and local of dependencies of Node.js?
    1. Globally installed packages are stored in < user-directory>/npm directory and these dependencies used in CLI (command line interface) of any node.js.
    2. NPM will install the dependencies in local mode by default. Local mode refers to package installation in node_modules directory lying in the folder where node application is present.
    Q9-: Explain child process module and why to use exec, fork, spawn() method for child process module?

    To create child process module you have following three ways-:

    1. Spawn-:

      It launches new process with command child.process.spawn.

    2. Exec –

      child_process_exec method runs command in shell/console and buffers the output.

    3. Fork –

      It is special case of spawn to create child processes command as child_process.fork.

    “exec()” method buffers the output by run the command in a shell. Command is as below-:

    Child_process.exec(command[,options], callback)

    “spawn()” method used to launch new process with given commands and method signature is as below-:

    Child_process.spawn(command[, args] [, options])

    “fork()” method is special case of “spawn()” for creating node processes. The method signature –

    Child_process.fork(modulePath[, args] [, options])

    Q10-: Explain Stream Pipe method in Node.js ?

    Stream method denoted as stream.pipe(), this method used for taking readable stream and connect it to writeable stream. Streams in node.js used to handle asynchronous process. It also helps in buffer data, it collects the data as it comes in until you are ready to use it or until all the data has arrived from stream.

    Copyright 1999- Ducat Creative, All rights reserved.

    Anda bisa mendapatkan server slot online resmi dan terpercaya tentu saja di sini. Sebagai salah satu provider yang menyediakan banyak pilihan permainan.