Here we have mentioned most frequently asked Node.js Interview Questions and Answers specially for freshers and experienced.


 

1. What is Node.js?

Ans:

Node.js is a very powerful JavaScript based platform or framework which is built on Google Chrome’s JavaScript V8 Engine.

2. Why to use Node.js?

Ans:

It is used to develop I/O intensive web applications like video streaming sites, single page applications (SPA) and other web applications. Node.js is open source and used by thousands of developers around the world.

3. Who developed Node.js?

Ans:

Node.js was developed in 2009 by Ryan Dahl.

4. What are the features of Node.js?

Ans:

Below are the features of Node.js –
Very Fast
Event driven and Asynchronous
Single Threaded but highly Scalable

5. Explain REPL in Node.js?

Ans:

REPL stands for Read Eval Print Loop. Node.js comes with bundled REPL environment which performs the following desired tasks –
Eval
Print
Loop
Read

6. Explain variables in Node.js?

Ans:

Variables are used to store values and print later like any conventional scripts. If “var” keyword is used then value is stored in variable. You can print the value in the variable using – console.log().
Eg:
$ node
> a = 30
30
> var b = 50
undefined
> a + b
80
> console.log(“Hi”)
Hi
undefined

7. What is the latest version of Node.js available?

Ans:

Latest version of Node.js is – v0.10.36.

8. List out some REPL commands in Node.js?

Ans:

Below are the list of REPL commands –
Ctrl + c – For terminating the current command.
Ctrl + c twice – For terminating REPL.
Ctrl + d – For terminating REPL.
Tab Keys – list of all the current commands.
.break – exit from multiline expression.
.save with filename – save REPL session to a file.

9. Mention the command to stop REPL in Node.js?

Ans:

Command – ctrl + c twice is used to stop REPL.

10. Explain NPM in Node.js?

Ans:

NPM stands for Node Package Manager (npm) and there are two functionalities which NPM takes care of mainly and they are –
Online repositories for node.js modules or packages, which can be searched on search.nodejs.org
Dependency Management, Version Management and command line utility for installing Node.js packages.



 

11. Mention command to verify the NPM version in Node.js?

Ans:

Below command can be used to verify the NPM version –
$ npm –version

12. How you can update NPM to new version in Node.js?

Ans:

Below commands can be used for updating NPM to new version –
$ sudo npm install npm -g
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
npm@2.7.1 /usr/lib/node_modules/npm

13. Explain callback in Node.js?

Ans:

Callback is called once the asynchronous operation has been completed. Node.js heavily uses callbacks and all API’s of Node.js are written to support callbacks.

14. How Node.js can be made more scalable?

Ans:

Node.js works good for I/O bound and not CPU bound work. For instance if there is a function to read a file, file reading will be started during that instruction and then it moves onto next instruction and once the I/O is done or completed it will call the callback function. So there will not be any blocking.

15. Explain global installation of dependencies?

Ans:

Globally installed dependencies or packages are stored in /npm directory and these dependencies can be used in Command Line Interface function of any node.js.

16. Explain local installation of dependencies?

Ans:

By default npm will install the dependency in the local mode. Here local mode refers to the package installation in node_modules directory lying in the folder where Node application is present. “require ()” is used to access the locally deployed packages.

17. Explain Package.JSON?

Ans:

This will be present in the root directory of any Node module/application and will be used to define the properties of a package.

18. Explain “Callback hell”?

Ans:

“Callback hell” will be referred to heavily nested callbacks which has become unreadable or unwieldly.

19. What are “Streams” in Node.JS?

Ans:

“Streams” are objects which will let you read the data from source and write data to destination as a continuous process.

20. What you mean by chaining in Node.JS?

Ans:

It’s a mechanism in which output of one stream will be connected to another stream and thus creating a chain of multiple stream operations.




 

21. Explain Child process module?

Ans:

Child process module has following three major ways to create child processes –
spawn – child_process.spawn launches a new process with a given command.
exec – child_process.exec method runs a command in a shell/console and buffers the output.
fork – The child_process.fork method is a special case of the spawn() to create child processes.

22. Why to use exec method for Child process module?

Ans:

“exec” method runs a command in a shell and buffers the output. Below is the command –
child_process.exec(command[, options], callback)

23. List out the parameters passed for Child process module?

Ans:

Below are the list of parameters passed for Child Process Module –
child_process.exec(command[, options], callback)
command – This is the command to run with space-separated arguments.
options – This is an object array which comprises one or more following options –
cwd
uid
gid
killSignal
maxBuffer
encoding
env
shell
timeout
callback – This is the function which is gets 2 arguments – stdout, stderr and error.

24. What is the use of method – “spawn()”?

Ans:

This method is used to launch a new process with the given commands. Below is the method signature –
child_process.spawn(command[, args][, options])

25. What is the use of method – “fork()”?

Ans:

This method is a special case for method- “spawn()” for creating node processes. The method signature –
child_process.fork(modulePath[, args][, options])

26. Explain Piping Stream?

Ans:

This is a mechanism of connecting one stream to other and this is basically used for getting the data from one stream and pass the output of this to other stream.

27. What would be the limit for Piping Stream?

Ans:

There will not be any limit for piping stream.

28. Explain FS module ?

Ans:

Here FS stands for “File System” and fs module is used for File I/O. FS module can be imported in the following way –
var test = require(“fs”)

29. Explain “Console” in Node.JS?

Ans:

“Console” is a global object and will be used for printing to stderr and stdout and this will be used in synchronous manner in case of destination is either file or terminal or else it is used in asynchronous manner when it is a pipe.

30. Explain – “console.log([data][, …])” statement in Node.JS?

Ans:

This statement is used for printing to “stdout” with newline and this function takes multiple arguments as “printf()”.


 

31. What you mean by “process”?

Ans:

“process” is a global object and will be used to represent a node process.

32. Explain exit codes in Node.JS? List out some exit codes?

Ans:

Exit code will be used when the process needs to be ended with specified code. Below are the list of exit codes in Node.JS –
Fatal Error
Non-function Internal Exception Handler
Internal JavaScript Parse Error
Uncaught Fatal Exception
Unused
Internal JavaScript Evaluation Failure
Internal Exception Handler Run-Time Failure

33. List out the properties of process?

Ans:

Below are the useful properties of process –
Platform
Stdin
Stdout
Stderr
execPath
mainModule
execArgv
config
arch
title
version
argv
env
exitCode

34. Define OS module?

Ans:

OS module is used for some basic operating system related utility functions. Below is the syntax for importing OS module –
var MyopSystem = require(“os”)

35. What is the property of OS module?

Ans:

os.EOL – Constant for defining appropriate end of line marker for OS.

36. Explain “Path” module in Node.JS?

Ans:

“Path” module will be used for transforming and handling file paths. Below is the syntax of path module –
var mypath = require(“path”)

37. Explain “Net” module in Node.JS?

Ans:

“Net” module is being used for creating both clients and servers. It will provide asynchronous network wrapper. Below is the syntax of Net module –
var mynet = require(“net”)

38. List out the differences between AngularJS and NodeJS?

Ans:

AngularJS is a web application development framework. It’s a JavaScript and it is different from other web app frameworks written in JavaScript like jQuery. NodeJS is a runtime environment used for building server-side applications while AngularJS is a JavaScript framework mainly useful in building/developing client-side part of applications which run inside a web browser.

39. NodeJS is client side server side language?

Ans:

NodeJS is a runtime system, which is used for creating server-side applications.

40. What are the advantages of NodeJS?

Ans:

Below are the list of advantages of NodeJS –
Javascript – It’s a javascript which can be used on frontend and backend.
Community Driven – NodeJS has great open source community which has developed many excellent modules for NodeJS to add additional capabilities to NodeJS applications.



 

41. In which scenarios NodeJS works well?

Ans:

NodeJS is not appropriate to use in scenarios where single-threaded calculations are going to be the holdup.

42. What you mean by JSON?

Ans:

JavaScript Object Notation (JSON) is a practical, compound, widely popular data exchange format. This will enable JavaScript developers to quickly construct APIs.

43. Explain “Stub”?

Ans:

Stub is a small program, which substitutes for a longer program, possibly to be loaded later and that is located remotely. Stubs are functions/programs that simulate the behaviors of components/modules.

44. List out all Node.JS versions available?

Ans:

Below are the list of all NodsJS versions supported in operating systems –

OperatingSystem

Node.js version

Windows

node-v0.12.0-x64.msi

Linux

node-v0.12.0-linux-x86.tar.gz

Mac

node-v0.12.0-darwin-x86.tar.gz

SunOS

node-v0.12.0-sunos-x86.tar.gz

45. Explain “Buffer class” in Node.JS?

Ans:

It is a global class which can be accessed in an application without importing buffer modules.

46. How we can convert Buffer to JSON?

Ans:

The syntax to convert Buffer to JSON is as shown beow
buffer.toJSON()

47. How to concatenate buffers in NodeJS?

Ans:

The syntax to concatenate buffers in NodeJS is
var MyConctBuffer = Buffer.concat([myBuffer1, myBuffer2]);

48. How to compare buffers in NodeJS?

Ans:

To compare buffers in NodeJS, use following code –
Mybuffer1.compare(Mybuffer2);

49. How to copy buffers in NodeJS?

Ans:

Below is the syntax to copy buffers in NodeJS –
buffer.copy(targetBuffer[, targetStart][, sourceStart][, sourceEnd])

50. What are the differences between “readUIntBE” and “writeIntBE” in Node.JS?

Ans:

readUIntBE – It’s a generalized version of all numeric read methods, which supports up to 48 bits accuracy. Setting noAssert to “true” to skip the validation.
writeIntBE – This will write the value to the buffer at the specified byteLength and offset and it supports upto 48 bits of accuracy.




 

51. Why to use “__filename” in Node.JS?

Ans:

“__filename” is used to represent the filename of the code which is being executed. It used to resolve the absolute path of file. Below is the sample code for the same –
Console.log(__filename);

52. Why to use “SetTimeout” in Node.JS?

Ans:

This is the global function and it is used to run the callback after some milliseconds.
Syntax of this method –
setTimeout(callbackmethod, millisecs)

53. Why to use “ClearTimeout” in Node.JS?

Ans:

This is the global function and it is used to stop a timer which was created during “settimeout()”.

54. Explain Web Server?

Ans:

It is a software app which will handle the HTTP requests by client (eg: browser) and will return web pages to client as a response. Most of web server supports – server side scripts using scripting languages. Example of web server is Apache, which is mostly used webserver.

55. List out the layers involved in Web App Architechure?

Ans:

Below are the layers used in Web Apps –
Client – Which makes HTTP request to the server. Eg: Browsers.
Server – This layer is used to intercept the requests from client.
Business – It will have application server utilized by web servers for processing.
Data – This layer will have databases mainly or any source of data.

56. Explain “Event Emitter” in Node.JS?

Ans:

It is a part of Events module. When instance of EventEmitter faces any error, it will emit an ‘error’ event. “Event Emitters” provides multiple properties like – “emit” and “on”.
“on” property is used for binding the function with event.
“emit” property is used for firing an event.

57. Explain “NewListener” in Node.JS?

Ans:

This event is being emitted whenever any listener is added. So when event is triggered the listener may not have been removed from listener array for the event.

58. Why to use Net.socket in Node.JS?

Ans:

This object is an abstraction of a local socket or TCP. net.Socket instances implement a duplex Stream interface. These can be created by the user and used as a client (with connect() function) or they can be created by Node and can be passed to the user through the ‘connection’ event of a server.

59. Which events are emitted by Net.socket?

Ans:

Below are the list of events emitted by Net.socket –
Connect
Lookup
End
Data
Close
Drain
Timeout
Error

60. Explain “DNS module” in Node.JS?

Ans:

This module is used for DNS lookup and to use underlying OS name resolution. This used to provide asynchronous network wrapper. DNS module can be imported like –
var mydns = require(“dns”)


 

61. Explain binding in domain module in Node.JS?

Ans:

Below are the bindings in domain modules –
External Binding
Internal Binding

62. Explain RESTful Web Service?

Ans:

Web services which uses REST architecture will be known as RESTful Web Services. These web services uses HTTP protocol and HTTP methods.

63. How to truncate the file in Node.JS?

Ans:

Below command can be used for truncating the file –
fs.ftruncate(fd, len, callback)

64. What is Node? and Why to use it

Ans:

Node.js is JavaScript run time framework built on top of Google V8 engine. One of the key reason to use Node is to perform asynchronous I/O operation.

65. What is the area of problem Node addresses

Ans:

Key areas of problem Node addresses:
Slow web servers due to synchronous I/O.
Multithreaded programming bottlenecks.
Scaling.
Package management and deployment.

66. Why Node uses Google V8 Engine

Ans:

Google V8 is Chrome runtime engine which converts JavaScript code into native machine code which in turn provides a fast running application.

67. Can we use other engines than V8

Ans:

Yes. Microsoft Chakra is another JavaScript engine which can be used with Node.js. It’s not officially declared yet.

68. If Node is single threaded then how it handles concurrency

Ans:

Node provides a single thread to programmers so that code can be written easily and without bottleneck. Node internally uses multiple POSIX threads for various I/O operations such as File, DNS, Network calls etc.
When Node gets I/O request it creates or uses a thread to perform that I/O operation and once the operation is done, it pushes the result to the event queue. On each such event, event loop runs and checks the queue and if the execution stack of Node is empty then it adds the queue result to execution stack.
This is how Node manages concurrency.

69. Explain event loop

Ans:

As said, Node.js is single threaded but it supports concurrency using events and callbacks. The event loop is a component which checks event queue on a periodic basis and pushes the result in execution stack if the stack is empty.

70. Which is your preferred way to write asynchronous code in Node

Ans:

Here is a list of methods I generally use to avoid callback hell and write asynchronous code.
Using Async module.
Using promises.
Using function decomposition.
Using async/await.
I personally prefer Async npm module.



 

71. What is stream and explain types of streams

Ans:

Streams are a collection of data that might not be available all at once and don’t have to fit in memory. Streams provide chunks of data in a continuous manner. It is useful to read a large set of data and process it.
There is 4 fundamental type of streams:
Readable.
Writeable.
Duplex.
Transform.
Readable streams as the name suggest used in reading a large chunk of data from a source. Writable streams are used in writing a large chunk of data to the destination.
Duplex streams are both readable and writable ( Eg socket). Transform stream is the duplex stream which is used in modifying the data (eg zip creation).

72. Explain child processes in Node

Ans:

Child process module enables us to access operating system functionaries. Scalability is baked into Node and child processes are the key factors to scale our application. You can use child process to run system commands, read large files without blocking event loop, decompose the application into various “nodes” (That’s why it’s called Node).

73. Can we send/receive messages between child processes

Ans:

Yes, we can.
We can use send() function to send message to workers and receive the response on process.on(‘message’) event.

74. Explain file system module of Node

Ans:

Node fs module provides simple file system module to perform files related operation. This module comprises of synchronous and asynchronous functions to read/write files. For example, readFile() function is asynchronous function to read file content from specified path and readFileSync() is synchronous function to read files.

75. How to scale Node application

Ans:

We can scale Node application in following ways:
cloning using cluster module.
Decomposing the application into smaller services – i.e micro services.

76. List down your favorite and most useful NPM library

Ans:

You should list down your favorite node module along with reasons.

77. How to deploy Node application

Ans:

You should know how to deploy Node application on various cloud providers. If you know the basics, such as SSH access, git cloning and running the application in process manager then more or less the steps are same in various cloud providers.
Reference: Hosting Node.js app to DigitalOcean Server
We will keep adding questions as found or suggested by readers.
You should also learn or revise few core JavaScript basics such as:
Closures
Prototype chaining.
Data structure in JavaScript such as stack, queue, linked list etc
How to create classes and perform inheritance.
Explain scoping in JavaScript.

78. NodeJS is client side server side language?

Ans:

NodeJS is a runtime system, which is used for creating server-side applications.

79. What are the advantages of NodeJS?

Ans:

Below are the list of advantages of NodeJS –
Javascript – It’s a javascript which can be used on frontend and backend.
Community Driven – NodeJS has great open source community which has developed many excellent modules for NodeJS to add additional capabilities to NodeJS applications.

80. In which scenarios NodeJS works well?

Ans:

NodeJS is not appropriate to use in scenarios where single-threaded calculations are going to be the holdup.




 

81. What is node.js?

Ans:

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.

82. How node.js works?

Ans:

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.

83. What do you mean by the term I/O ?

Ans:

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.

84. What does event-driven programming mean?

Ans:

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

85. Where can we use node.js?

Ans:

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

86. What is the advantage of using node.js?

Ans:

a) It provides an easy way to build scalable network programs
b) Generally fast
c) Great concurrency
d) Asynchronous everything
e) Almost never blocks

87. What are the two types of API functions in Node.js ?

Ans:

The two types of API functions in Node.js are
a) Asynchronous, non-blocking functions
b) Synchronous, blocking functions

88. What is control flow function?

Ans:

A generic piece of code which runs in between several asynchronous function calls is known as control flow function.

89. Explain the steps how “Control Flow” controls the functions calls?

Ans:

a) Control the order of execution
b) Collect data
c) Limit concurrency
d) Call the next step in program

90. Why Node.js is single threaded?

Ans:

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.


 

91. Does node run on windows?

Ans:

Yes – it does. Download the MSI installer from http://nodejs.org/download/

92. Can you access DOM in node?

Ans:

No, you cannot access DOM in node.

93. Using the event loop what are the tasks that should be done asynchronously?

Ans:

a) I/O operations
b) Heavy computation
c) Anything requiring blocking

94. Why node.js is quickly gaining attention from JAVA programmers?

Ans:

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.

95. What are the two arguments that async.queue takes?

Ans:

The two arguments that async.queue takes
a) Task function
b) Concurrency value

96. What is an event loop in Node.js ?

Ans:

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 .

97. Mention the steps by which you can async in Node.js?

Ans:

By following steps you can async Node.js
a) First class functions
b) Function composition
c) Callback Counters
d) Event loops

98. What are the pros and cons of Node.js?

Ans:

Pros:
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.
Cons:
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

99. How Node.js overcomes the problem of blocking of I/O operations?

Ans:

Node.js solves this problem by putting the event based model at its core, using an event loop instead of threads.

100. What is the difference between Node.js vs Ajax?

Ans:

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.



 

101. What are the Challenges with Node.js ?

Ans:

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.

102. What does it mean “non-blocking” in node.js?

Ans:

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.

103. What is the command that is used in node.js to import external libraries?

Ans:

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.

104. Mention the framework most commonly used in node.js?

Ans:

“Express” is the most common framework used in node.js

105. What is ‘Callback’ in node.js?

Ans:

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.

106. Explain variables in Node.js?

Ans:

Variables are used to store values and print later like any conventional scripts. If “var” keyword is used then value is stored in variable. You can print the value in the variable using – console.log().
Eg:
$ node
> a = 30
30
> var b = 50
undefined
> a + b
80
> console.log(“Hi”)
Hi
undefined

107. What is the latest version of Node.js available?

Ans:

Latest version of Node.js is – v0.10.36.

108. List out some REPL commands in Node.js?

Ans:

Below are the list of REPL commands –
Ctrl + c – For terminating the current command.
Ctrl + c twice – For terminating REPL.
Ctrl + d – For terminating REPL.
Tab Keys – list of all the current commands.
.break – exit from multiline expression.
.save with filename – save REPL session to a file.

109. Mention the command to stop REPL in Node.js?

Ans:

Command – ctrl + c twice is used to stop REPL.

110. Explain NPM in Node.js?

Ans:

NPM stands for Node Package Manager (npm) and there are two functionalities which NPM takes care of mainly and they are –
Online repositories for node.js modules or packages, which can be searched on search.nodejs.org
Dependency Management, Version Management and command line utility for installing Node.js packages.




 

111. Mention command to verify the NPM version in Node.js?

Ans:

Below command can be used to verify the NPM version –
$ npm –version

112. How you can update NPM to new version in Node.js?

Ans:

Below commands can be used for updating NPM to new version –
$ sudo npm install npm -g
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
npm@2.7.1 /usr/lib/node_modules/npm

113. Explain callback in Node.js?

Ans:

Callback is called once the asynchronous operation has been completed. Node.js heavily uses callbacks and all API’s of Node.js are written to support callbacks.

114. How Node.js can be made more scalable?

Ans:

Node.js works good for I/O bound and not CPU bound work. For instance if there is a function to read a file, file reading will be started during that instruction and then it moves onto next instruction and once the I/O is done or completed it will call the callback function. So there will not be any blocking.

115. Explain global installation of dependencies?

Ans:

Globally installed dependencies or packages are stored in /npm directory and these dependencies can be used in Command Line Interface function of any node.js.

116. Explain local installation of dependencies?

Ans:

By default npm will install the dependency in the local mode. Here local mode refers to the package installation in node_modules directory lying in the folder where Node application is present. “require ()” is used to access the locally deployed packages.

117. Explain Package.JSON?

Ans:

This will be present in the root directory of any Node module/application and will be used to define the properties of a package.

118. Explain “Callback hell”?

Ans:

“Callback hell” will be referred to heavily nested callbacks which has become unreadable or unwieldly.

119. What are “Streams” in Node.JS?

Ans:

“Streams” are objects which will let you read the data from source and write data to destination as a continuous process.

120. What you mean by chaining in Node.JS?

Ans:

It’s a mechanism in which output of one stream will be connected to another stream and thus creating a chain of multiple stream operations.


 

121. Explain Child process module?

Ans:

Child process module has following three major ways to create child processes –
spawn – child_process.spawn launches a new process with a given command.
exec – child_process.exec method runs a command in a shell/console and buffers the output.
fork – The child_process.fork method is a special case of the spawn() to create child processes.

122. Why to use exec method for Child process module?

Ans:

“exec” method runs a command in a shell and buffers the output. Below is the command –
child_process.exec(command[, options], callback)

123. List out the parameters passed for Child process module?

Ans:

Below are the list of parameters passed for Child Process Module –
child_process.exec(command[, options], callback)
command – This is the command to run with space-separated arguments.
options – This is an object array which comprises one or more following options –
cwd
uid
gid
killSignal
maxBuffer
encoding
env
shell
timeout
callback – This is the function which is gets 2 arguments – stdout, stderr and error.

124. What is the use of method – “spawn()”?

Ans:

This method is used to launch a new process with the given commands. Below is the method signature –
child_process.spawn(command[, args][, options])

125. What is the use of method – “fork()”?

Ans:

This method is a special case for method- “spawn()” for creating node processes. The method signature –
child_process.fork(modulePath[, args][, options])

126. Explain Piping Stream?

Ans:

This is a mechanism of connecting one stream to other and this is basically used for getting the data from one stream and pass the output of this to other stream.

127. What would be the limit for Piping Stream?

Ans:

There will not be any limit for piping stream.

128. Explain FS module ?

Ans:

Here FS stands for “File System” and fs module is used for File I/O. FS module can be imported in the following way –
var test = require(“fs”)

129. Explain “Console” in Node.JS?

Ans:

“Console” is a global object and will be used for printing to stderr and stdout and this will be used in synchronous manner in case of destination is either file or terminal or else it is used in asynchronous manner when it is a pipe.

130. Explain – “console.log([data][, …])” statement in Node.JS?

Ans:

This statement is used for printing to “stdout” with newline and this function takes multiple arguments as “printf()”.



 

131. What you mean by “process”?

Ans:

“process” is a global object and will be used to represent a node process.

132. Explain exit codes in Node.JS? List out some exit codes?

Ans:

Exit code will be used when the process needs to be ended with specified code. Below are the list of exit codes in Node.JS –
Fatal Error
Non-function Internal Exception Handler
Internal JavaScript Parse Error
Uncaught Fatal Exception
Unused
Internal JavaScript Evaluation Failure
Internal Exception Handler Run-Time Failure

133. Define OS module?

Ans:

OS module is used for some basic operating system related utility functions. Below is the syntax for importing OS module –
var MyopSystem = require(“os”)

134. What is the property of OS module?

Ans:

os.EOL – Constant for defining appropriate end of line marker for OS.

135. Explain “Path” module in Node.JS?

Ans:

“Path” module will be used for transforming and handling file paths. Below is the syntax of path module –
var mypath = require(“path”)

136. Explain “Net” module in Node.JS?

Ans:

“Net” module is being used for creating both clients and servers. It will provide asynchronous network wrapper. Below is the syntax of Net module –
var mynet = require(“net”)

137. List out the differences between AngularJS and NodeJS?

Ans:

AngularJS is a web application development framework. It’s a JavaScript and it is different from other web app frameworks written in JavaScript like jQuery. NodeJS is a runtime environment used for building server-side applications while AngularJS is a JavaScript framework mainly useful in building/developing client-side part of applications which run inside a web browser.