Node JS Q&A

[vc_row][vc_column css_animation=”fadeInLeft”][vc_column_text css=”.vc_custom_1562234764572{background-color: #1e73be !important;}”]

Node JS Interview Questions & Answers

[/vc_column_text][/vc_column][/vc_row][vc_row css_animation=”fadeInRight”][vc_column css_animation=”fadeInLeft” width=”1/2″][vc_tta_accordion color=”peacoc” active_section=”1″][vc_tta_section title=” What is node.js?” tab_id=”1562234866388-4549f21c-ed32″][vc_column_text]Node.js is a Server side scripting which is used to build scalable programs. Its multiple advantages over other server side languages, the prominent being non-blocking I/O.[/vc_column_text][/vc_tta_section][vc_tta_section title=” How node.js works?” tab_id=”1562234866405-300500d4-8f78″][vc_column_text]Node.js works on a v8 environment, it is a virtual machine that utilizes JavaScript as its scripting language and achieves high output via non-blocking I/O and single threaded event loop.[/vc_column_text][/vc_tta_section][vc_tta_section title=” What do you mean by the term I/O ?” tab_id=”1562234904405-705f04f6-6f8f”][vc_column_text]I/O is the shorthand for input and output, and it will access anything outside of your application. It will be loaded into the machine memory to run the program, once the application is started.

[/vc_column_text][/vc_tta_section][vc_tta_section title=” What does event-driven programming mean?” tab_id=”1562234904900-61d5e53f-be3a”][vc_column_text]In computer programming, event driven programming is a programming paradigm in which the flow of the program is determined by events like messages from other programs or threads. It is an application architecture technique divided into two sections 1) Event Selection 2) Event Handling[/vc_column_text][/vc_tta_section][vc_tta_section title=”Where can we use node.js?” tab_id=”1562234905475-696bac8b-41f3″][vc_column_text]Node.js can be used for the following purposes

a)      Web applications ( especially real-time web apps )

b)      Network applications

c)       Distributed systems

d)      General purpose applications[/vc_column_text][/vc_tta_section][vc_tta_section title=” What is the advantage of using node.js?” tab_id=”1562234906010-db6afd67-e9b6″][vc_column_text]a)      It provides an easy way to build scalable network programs

b)      Generally fast

c)       Great concurrency

d)      Asynchronous everything

e)      Almost never blocks[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the two types of API functions in Node.js ?” tab_id=”1562234906573-2b4abc97-f949″][vc_column_text]The two types of API functions in Node.js are

a)      Asynchronous, non-blocking functions

b)      Synchronous, blocking functions[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is control flow function?” tab_id=”1562234907070-c0469bc4-055f”][vc_column_text]A generic piece of code which runs in between several asynchronous function calls is known as control flow function.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Explain the steps how “Control Flow” controls the functions calls?” tab_id=”1562234907679-f46a9988-25ee”][vc_column_text]a)      Control the order of execution

b)      Collect data

c)       Limit concurrency

d)      Call the next step in program[/vc_column_text][/vc_tta_section][vc_tta_section title=”Why Node.js is single threaded?” tab_id=”1562234908398-5eef6abb-5c9c”][vc_column_text]For async processing, Node.js was created explicitly as an experiment. It is believed that more performance and scalability can be achieved by doing async processing on a single thread under typical web loads than the typical thread based implementation.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Does node run on windows?” tab_id=”1562234909078-47930d83-b9e9″][vc_column_text]Yes – it does. Download the MSI installer from[/vc_column_text][/vc_tta_section][vc_tta_section title=”Can you access DOM in node?” tab_id=”1562234909766-371d7a1d-efbb”][vc_column_text]No, you cannot access DOM in node.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Using the event loop what are the tasks that should be done asynchronously?” tab_id=”1562234910338-ebb0b2b5-46e1″][vc_column_text]a)      I/O operations

b)      Heavy computation

c)       Anything requiring blocking[/vc_column_text][/vc_tta_section][/vc_tta_accordion][/vc_column][vc_column width=”1/2″][vc_tta_accordion color=”peacoc” active_section=”1″][vc_tta_section title=”Why node.js is quickly gaining attention from JAVA programmers?” tab_id=”1562234926143-254b16e4-499e”][vc_column_text]Node.js is quickly gaining attention as it is a loop based server for JavaScript. Node.js gives user the ability to write the JavaScript on the server, which has access to things like HTTP stack, file I/O, TCP and databases.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the two arguments that async.queue takes?” tab_id=”1562234926160-79160726-8a79″][vc_column_text]The two arguments that async.queue takes

a)      Task function

b)      Concurrency value[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is an event loop in Node.js ?” tab_id=”1562234936510-bf489a5c-f0e8″][vc_column_text]To process and handle external events and to convert them into callback invocations an event loop is used. So, at I/O calls, node.js can switch from one request to another .[/vc_column_text][/vc_tta_section][vc_tta_section title=”Mention the steps by which you can async in Node.js?” tab_id=”1562234937558-48c1f439-c2d7″][vc_column_text]By following steps you can async Node.js

a)      First class functions

b)      Function composition

c)       Callback Counters

d)      Event loops[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the pros and cons of Node.js?” tab_id=”1562234938130-4c725db4-3002″][vc_column_text]a)      If your application does not have any CPU intensive computation, you can build it in Javascript top to bottom, even down to the database level if you use JSON storage object DB like MongoDB.

b)      Crawlers receive a full-rendered HTML response, which is far more SEO friendly rather than a single page application or a websockets app run on top of Node.js.


a)       Any intensive CPU computation will block node.js responsiveness, so a threaded platform is a better approach.
b)      Using relational database with Node.js is considered less favourable[/vc_column_text][/vc_tta_section][vc_tta_section title=”How Node.js overcomes the problem of blocking of I/O operations?” tab_id=”1562234938743-b0fab518-0547″][vc_column_text]Node.js solves this problem by putting the event based model at its core, using an event loop instead of threads.[/vc_column_text][/vc_tta_section][vc_tta_section title=” What is the difference between Node.js vs Ajax?” tab_id=”1562234939262-a11d7b6c-d03e”][vc_column_text]The difference between Node.js and Ajax is that, Ajax (short for Asynchronous Javascript and XML) is a client side technology, often used for updating the contents of the page without refreshing it. While,Node.js is Server Side Javascript, used for developing server software. Node.js does not execute in the browser but by the server.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the Challenges with Node.js ?” tab_id=”1562234939992-01def9de-4ded”][vc_column_text]Emphasizing on the technical side, it’s a bit of challenge in Node.js to have one process with one thread to scale up on multi core server.[/vc_column_text][/vc_tta_section][vc_tta_section title=” What does it mean “non-blocking” in node.js?” tab_id=”1562234940550-4ef33815-0345″][vc_column_text]In node.js “non-blocking” means that its IO is non-blocking.  Node uses “libuv” to handle its IO in a platform-agnostic way. On windows, it uses completion ports for unix it uses epoll or kqueue etc. So, it makes a non-blocking request and upon a request, it queues it within the event loop which call the JavaScript ‘callback’ on the main JavaScript thread.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is the command that is used in node.js to import external libraries?” tab_id=”1562234941035-04899494-80e9″][vc_column_text]Command “require” is used for importing external libraries, for example, “var http=require (“http”)”.  This will load the http library and the single exported object through the http variable.[/vc_column_text][/vc_tta_section][vc_tta_section title=” Mention the framework most commonly used in node.js?” tab_id=”1562234941655-00c01566-f028″][vc_column_text]“Express” is the most common framework used in node.js[/vc_column_text][/vc_tta_section][vc_tta_section title=” What is ‘Callback’ in node.js?” tab_id=”1562234944494-f9582020-1523″][vc_column_text]Callback function is used in node.js to deal with multiple requests made to the server. Like if you have a large file which is going to take a long time for a server to read and if you don’t want a server to get engage in reading that large file while dealing with other requests, call back function is used. Call back function allows the server to deal with pending request first and call a function when it is finished.[/vc_column_text][/vc_tta_section][/vc_tta_accordion][/vc_column][/vc_row]

WhatsApp us