Node.JS Interview Questions and Answers For Freshers Part-1
2.What do you mean by Asynchronous API?
All APIs of Node.js library are aynchronous that is non-blocking. It essentially means a Node.js based server never waits for a API to return data. Server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call.
3.What are the benefits of using Node.js?
Following are main benefits of using Node.js
Aynchronous and Event DrivenAll APIs of Node.js library are aynchronous that is non-blocking. It essentially means a Node.js based server never waits for a API to return data. Server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call.
Single Threaded but highly Scalable – Node.js uses a single threaded model with event looping. Event mechanism helps server to respond in a non-bloking ways and makes server highly scalable as opposed to traditional servers which create limited threads to handle requests. Node.js uses a single threaded program and same program can services much larger number of requests than traditional server like Apache HTTP Server.
No Buffering – Node.js applications never buffer any data. These applications simply output the data in chunks.
4.Is it free to use Node.js?
Yes! Node.js is released under the MIT license and is free to use.
5.Is Node a single threaded application?
Yes! Node uses a single threaded model with event looping.
6.What is REPL in context of Node?
REPL stands for Read Eval Print Loop and it represents a computer environment like a window console or unix/linux shell where a command is entered and system responds with an output. Node.js or Node comes bundled with a REPL environment. It performs the following desired tasks.
Eval – Takes and evaluates the data structure
Print – Prints the result
Loop – Loops the above command until user press ctrl-c twice.
7.Can we evaluate simple expression using Node REPL
8.What is the difference of using var and not using var in REPL while dealing with variables?
Use variables to store values and print later. if var keyword is not used then value is stored in the variable and printed. Wheras if var keyword is used then value is stored but not printed. You can use both variables later.
9.What is the use of Underscore variable in REPL?
Use _ to get the last result.
> var x = 10
> var y = 20
> x + y
> var sum = _
10.What is npm?
npm stands for Node Package Manager. npm provides following two main functionalities:
Online repositories for node.js packages/modules which are searchable on search.nodejs.org
Command line utility to install packages, do version management and dependency management of Node.js packages.