Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

Node.JS Interview Questions and Answers For Freshers Part-1

Be First!

nodejs1.What is Node.js?
Node.js is a web application framework built on Google Chrome’s JavaScript Engine(V8 Engine).

Node.js comes with runtime environment on which a Javascript based script can be interpreted and executed (It is analogus to JVM to JAVA byte code). This runtime allows to execute a JavaScript code on any machine outside a browser. Because of this runtime of Node.js, JavaScript is now can be executed on server as well.

Node.js also provides a rich library of various javascript modules which eases the developement of web application using Node.js to great extents.

Node.js = Runtime Environment + JavaScript Library

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.

Very Fast Being built on Google Chrome’s V8 JavaScript Engine, Node.js library is very fast in code execution.

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.

Read – Reads user’s input, parse the input into JavaScript data-structure and stores in memory.

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
Yes.

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.

C:\Nodejs_WorkSpace>node
> var x = 10
undefined
> var y = 20
undefined
> x + y
30
> var sum = _
undefined
> console.log(sum)
30
undefined
>
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.

(189)

Previous
Next

Leave a Reply