YouTube Icon

Interview Questions.

Node JS Interview Questions - Jul 17, 2022

fluid

Node JS Interview Questions

Q1. What is node.Js?

Ans: Node.Js is a Server facet scripting that's used to construct scalable packages. Its more than one advantages over different server aspect languages, the outstanding being non-blocking off I/O.

Q2. Where are we able to use node.Js?

Node.Js can be used for the following functions

Web programs ( in particular real-time web apps )

Network packages

Distributed systems

General motive applications

Q3. What is the benefit of using node.Js?

Ans: It provides an smooth manner to construct scalable network packages

Generally fast

Great concurrency

 Asynchronous the whole thing

 Almost never blocks

Q4. What are the 2 kinds of API capabilities in Node.Js ?

The  types of API functions in Node.Js are

Asynchronous, non-blockading functions

Synchronous, blocking off functions

Q5. What is manage drift feature?

Ans: A prevalent piece of code which runs in between numerous asynchronous characteristic calls is called manage float characteristic.

Q6. Why Node.Js is unmarried threaded?

Ans: For async processing, Node.Js became created explicitly as an experiment. It is thought that more performance and scalability may be completed by using doing async processing on a single thread beneath regular net masses than the everyday thread primarily based implementation.

Q7. Can you get admission to DOM in node?

Ans: No, you cannot access DOM in node.

Q8. Using the occasion loop what are the obligations that should be completed asynchronously?

Ans:

 I/O operations

 Heavy computation

 Anything requiring blocking off

Q9. Why node.Js is speedy gaining attention from JAVA programmers?

Ans: Node.Js is fast gaining interest as it's miles a loop based server for JavaScript. Node.Js gives user the potential to put in writing the JavaScript at the server, which has access to things like HTTP stack, record I/O, TCP and databases.

Q10. What is ‘Callback’ in node.Js?

Ans: Callback characteristic is utilized in node.Js to cope with a couple of requests made to the server. Like if you have a massive file which is going to take a long time for a server to study and in case you don’t need a server to get engage in reading that huge document at the same time as handling other requests, call lower back function is used. Call returned function allows the server to cope with pending request first and speak to a function when it's far completed.Refer our Node.Js Course for an additional records.

Q11. Mention the framework maximum normally utilized in node.Js?

Ans: “Express” is the most common framework used in node.Js

Q12. What is an event loop in Node.Js ?

Ans: To method and handle external activities and to transform them into callback invocations an occasion loop is used. So, at I/O calls, node.Js can transfer from one request to another .

Q13. Mention the steps via which you may async in Node.Js?

Ans: By following steps you may async Node.Js

First elegance functions

Function composition

Callback Counters

Event loops

Q14. What are the professionals and cons of Node.Js?

Ans:

Pros:

If your utility does now not have any CPU intensive computation, you may build it in Javascript top to backside, even all the way down to the database level in case you use JSON garage item DB like MongoDB.

Crawlers get hold of a complete-rendered HTML response, that is a ways greater search engine marketing friendly instead of a single web page application or a websockets app run on top of Node.Js.

Cons:

Any extensive CPU computation will block node.Js responsiveness, so a threaded platform is a higher technique.

Using relational database with Node.Js is taken into consideration much less favourable

Q15.   How Node.Js overcomes the problem of blockading of I/O operations?

Ans: Node.Js solves this trouble with the aid of setting the occasion based model at its center, using an occasion loop in preference to threads.

HubSpot Video
 

Q16. What is the distinction between Node.Js vs Ajax?

Ans: The distinction between Node.Js and Ajax is that, Ajax (short for Asynchronous Javascript and XML) is a patron side technology, often used for updating the contents of the web page without refreshing it. While,Node.Js is Server Side Javascript, used for developing server software. Node.Js does not execute within the browser however by using the server.

Q17. What are the Challenges with Node.Js ?

Ans: Emphasizing at the technical facet, it’s a chunk of task in Node.Js to have one process with one thread to scale up on multi center server.

Q18. What does it suggest “non-blocking” in node.Js?

Ans: In node.Js “non-blockading” manner that its IO is non-blocking off.  Node uses “libuv” to address its IO in a platform-agnostic manner. On home windows, it makes use of finishing touch ports for unix it makes use of epoll or kqueue etc. So, it makes a non-blockading request and upon a request, it queues it inside the occasion loop which name the JavaScript ‘callback’ on the primary JavaScript thread.

Q19. 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 unmarried exported object through the http variable.

Q20. What's your favourite HTTP framework and why?

Ans: There is no right answer for this. The goal right here is to understand how deeply one knows the framework she/he makes use of, if can cause approximately it, knows the pros, cons.

Q21. What's the distinction among operational and programmer errors?

Ans: Operation mistakes aren't insects, however troubles with the system, likerequest timeout or hardware failure.

On the alternative hand programmer errors are real insects.

Q22. What is the trendy model of Node.Js available?

Ans: Latest version of Node.Js is - v0.10.36.

Q23. What are the functions of Node.Js?

Ans: Below are the capabilities of Node.Js –

Very Fast

Event pushed and Asynchronous

Single Threaded but fantastically Scalable

Q24. Explain REPL in Node.Js?

Ans: REPL stands for Read Eval Print Loop. Node.Js comes with bundled REPL surroundings which plays the following favored obligations –

Eval

Print

Loop

Read

Q25. Explain variables in Node.Js?

Ans: Variables are used to store values and print later like all conventional scripts. If “var” key-word is used then price is stored in variable. You can print the cost within the variable the usage of - console.Log().

Eg:

$ node

> a = 30

30

> var b = 50

undefined

> a + b

eighty

> console.Log("Hi")

Hi

undefined

Q26. List out some REPL instructions in Node.Js?

Ans: Below are the list of REPL commands –

Ctrl + c - For terminating the modern command.

Ctrl + c twice – For terminating REPL.

Ctrl + d - For terminating REPL.

Tab Keys - listing of all the contemporary commands.

.Destroy - go out from multiline expression.

.Save with filename - save REPL consultation to a file.

Q27. Mention the command to prevent REPL in Node.Js?

Ans: Command - ctrl + c twice is used to prevent REPL.

Q28. Explain NPM in Node.Js?

Ans: NPM stands for Node Package Manager (npm) and there are  functionalities which NPM looks after in particular and they are –

Online repositories for node.Js modules or applications, which may be searched on search.Nodejs.Org

Dependency Management, Version Management and command line utility for installing Node.Js applications.

Q29. Mention command to verify the NPM version in Node.Js?

Ans: Below command can be used to verify the NPM model –

$ npm --version

Q30. How you may replace NPM to new version in Node.Js?

Ans: Below instructions may be used for updating NPM to new edition –

$ 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

Q31. Explain callback in Node.Js?

Ans: Callback is called once the asynchronous operation has been completed. Node.Js closely makes use of callbacks and all API’s of Node.Js are written to help callbacks.

Q32. How Node.Js can be made extra scalable?

Ans: Node.Js works exact for I/O sure and now not CPU certain work. For example if there's a function to study a document, record studying will be started out throughout that preparation after which it movements onto subsequent preparation and once the I/O is carried out or finished it's going to call the callback feature. So there will not be any blocking off.

Q33. Explain international set up of dependencies?

Ans: Globally set up dependencies or programs are saved in <user-directory>/npm directory and those dependencies can be used in Command Line Interface characteristic of any node.Js.

Q34. What you mean by using chaining in Node.JS?

Ans: It’s a mechanism in which output of 1 movement might be linked to any other circulate and thus developing a chain of a couple of circulate operations.

Q35. Explain Child system module?

Ans: Child system module has following 3 major approaches to create infant strategies –

spawn  - child_process.Spawn launches a new procedure with a given command.

Exec  - child_process.Exec approach runs a command in a shell/console and buffers the output.

Fork - The child_process.Fork technique is a special case of the spawn() to create infant tactics.

Q36. Why to use exec method for Child procedure module?

Ans: “exec” technique runs a command in a shell and buffers the output. Below is the command –

child_process.Exec(command[, options], callback)

Q37. List out the parameters exceeded for Child technique 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 item array which accommodates one or extra following options –

cwd

uid

gid

killSignal

maxBuffer

encoding

env

shell

timeout

callback – This is the characteristic that is receives 2 arguments – stdout, stderr and blunders.

Q38. What is the usage of method – “spawn()”?

Ans: This approach is used to release a brand new technique with the given instructions. Below is the method signature –

child_process.Spawn(command[, args][, options])

Q39. What is using technique – “fork()”?

Ans: This approach is a special case for method- “spawn()” for creating node procedures. The method signature –

child_process.Fork(modulePath[, args][, options])

Q40. Explain Piping Stream?

Ans: This is a mechanism of connecting one move to different and this is largely used for purchasing the facts from one move and pass the output of this to different flow.

Q41. What would be the limit for Piping Stream?

Ans: There will not be any restriction for piping stream.

Q42. Explain FS module ?

Ans: Here FS stands for “File System” and fs module is used for File I/O. FS module can be imported within the following manner –

var test = require("fs")

Q43. Explain “Console” in Node.JS?

Ans: “Console” is a global object and may be used for printing to stderr and stdout and this can be used in synchronous manner in case of destination is either document or terminal otherwise it is utilized in asynchronous manner while it's far a pipe.

Q44. Explain – “console.Log([data][, ...])” assertion in Node.JS?

Ans: This assertion is used for printing to “stdout” with newline and this feature takes a couple of arguments as “printf()”.

Q45. List out the homes of manner?

Below are the beneficial homes of manner –

Platform

Stdin

Stdout

Stderr

execPath

mainModule

execArgv

config

arch

identify

version

argv

env

exitCode

Q46. How to concatenate buffers in NodeJS?

Ans: The syntax to concatenate buffers in NodeJS is

var MyConctBuffer = Buffer.Concat([myBuffer1, myBuffer2]);

Q47. How to examine buffers in NodeJS?

Ans: To evaluate buffers in NodeJS, use following code –

Mybuffer1.Compare(Mybuffer2);

Q48. How to replicate buffers in NodeJS?

Ans: Below is the syntax to duplicate buffers in NodeJS –

buffer.Reproduction(targetBuffer[, targetStart][, sourceStart][, sourceEnd])

Q49. What are the variations between “readUIntBE” and “writeIntBE” in Node.JS?

Ans:

readUIntBE - It’s a generalized version of all numeric study techniques, which supports up to forty eight bits accuracy. Setting noAssert to “genuine” to bypass the validation.

WriteIntBE - This will write the price to the buffer at the specified byteLength and offset and it helps upto 48 bits of accuracy.

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

Ans: This is the worldwide characteristic and it's miles used to run the callback after a few milliseconds.

Syntax of this technique –

setTimeout(callbackmethod, millisecs)




CFG