Node.js Interview Questions and answers

41. In the context of Node.js, differentiate between operational and programmer errors.
Answer : Operational errors are not real errors. They are system errors, for example “request timeout” or “hardware error”. Programmer errors are actual bugs in the code.

42. What are the two arguments that async.queue takes?
Answer : The two arguments that async.queue takes
a)Task function
b)Concurrency value

43. What is an event loop in Node.js ?
Answer : 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 .

44. Mention the steps by which you can async in Node.js?
Answer : By following steps you can async Node.js
a)First class functions
b)Function composition
c)Callback Counters
d)Event loops

45. How to solve “Process out of Memory Exception” in Node.js ?
Answer : To solve the process out of memory exception in Node.js we need to increase the max-old-space-size. By default the max size of max-old-space-size is 512 mb which you can increase by the command node –max-old-space-size=1024 file.js.

46. How many types of API functions are available in Node.js?
Answer : There are two types of API functions in Node.js:
Asynchronous, Non-blocking functions
Synchronous, Blocking functions

47. Define “event-driven programming.
Answer : It is essentially a programming paradigm where the program flow is characterized by events such as messages from other programs.

48. List some of the big advantages of using Node.js.
Answer : Ability to build scalable programs
Increased concurrency
Asynchronous capabilities

49. What are the pros and cons of Node.js?
Answer :
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

50. How Node.js overcomes the problem of blocking of I/O operations?
Answer : Node.js solves this problem by putting the event based model at its core, using an event loop instead of threads.

test1

test1

Comments are closed here.