Node.js Interview Questions and answers

21. What is the difference between operational and programmer errors?
Answer : Operational errors are not bugs, but create problems with system like request timeout or hardware failure. On the other hand, programmer errors are actual bugs.

22. What is the fundamental difference between Node.js and Ajax?
Answer : While Ajax is a client-side technology, Node.js is a server-side JavaScript environment.

23. What are the two types of API functions in Node.js ?
Answer : The two types of API functions in Node.js are
a)Asynchronous, non-blocking functions
b)Synchronous, blocking functions

24. What is control flow function?
Answer : A generic piece of code which runs in between several asynchronous function calls is known as control flow function.

25. Explain the term I/O in the context of Node.js.
Answer : I/O stands for input and output. It is used to access anything outside of the application. I/O gets loaded on to the machine memory in order to run programs after the application is fired up.

26. What is the difference between process.nextTick() and setImmediate() ?
Answer : The difference between process.nextTick() and setImmediate() is that process.nextTick() defers the execution of an action till the next pass around the event loop or it simply calls the callback function once the ongoing execution of the event loop is finished whereas setImmediate() executes a callback on the next cycle of the event loop and it gives back to the event loop for executing any I/O operations.

27. Explain the steps how “Control Flow” controls the functions calls?
Answer :
a)Control the order of execution
b)Collect data
c)Limit concurrency
d)Call the next step in program

28. Why Node.js is single threaded?
Answer : 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.

29. State where Node.js can be used.
Answer : Web apps
Network applications
Distributed systems
General purpose applications

30. Does node run on windows?
Answer : Yes – it does.

COPY CODE SNIPPET