Got a programming interview coming up?
Preparing for it is as important as developing your coding knowledge to ace it.
Itll give you the confidence to handle the interview and shake off the jitters.

This is especially true if you are facing a programming interview for the first time in your life.
We wrote a post not so long ago oncommon JavaScript interview questionsto cover the basics.
How is Node.js different from Javascript?

40% off TNW Conference!
Node.js is asynchronous, event-driven, non-blocking, and single-threaded.
What does EventEmitter do?

Every object in Node.js capable of emitting events is a member of theEventEmitterclass.
Thehttpmodule is one such example.
AllEventEmitterclasses can use theeventEmitter.on()functionto attach event listeners to the event.

Then, as soon as such an event is caught, its listeners are called one by one synchronously.
What is Nodes event loop?
The event loop is responsible for enabling this non-blocking behavior.

Its job isto schedulepending tasks using the system thread.
Similar to the event that created the task, the completion of the task also emits an event.
Node.js adds these events that require handling to an event queue.

The event loop iterates over events in the event queue and schedules when to execute their associated callback functions.
What are Node Streams?
Streams are pipelines that read or write data from a source and transfer it to a continuous flow destination.

There are four types of streams:
Each stream is also anEventEmitter.
What is the difference between readFile and createReadStream functions?
createReadStreamoptimizes the file reading operation compared toreadFileby using less memory and making it faster.

How do you handle uncaught exceptions in Node.js?
We can catch uncaught exceptions thrown in the system at its process level.
We attach a listener to theprocessglobal object to catch such events.
Can Node take full advantage of a multi-processor system?
Node applications are always single-threaded.
So, naturally, the software uses only a single processor even when running on multi-processor systems.
What is the reactor design pattern used in Node.js?
The reactor pattern is used for maintaining non-blocking I/O operations in Node.js.
It attaches a callback function (a handler) to each I/O operation.
The handler is then submitted to a demultiplexer at the time of request creation.
Demultiplexer collects every I/O request made in the software and queues them as events in a queue.
This is what we call the event queue.
After queuing the event, the demultiplexer returns the control of the app thread.
This is the reactor pattern used by Node.js.
What are the benefits of a single-threaded web backend to a multi-threaded one?
In what way is having only a single thread is beneficial to backend development?
What is REPL in Node?
REPL stands for Read-Eval-Print-Loop.
It is a virtual environment where you’re free to run a programming language easily.
Node comes with a built-in REPL to run JavaScript code.
It is similar to the consoles we use in browsers to run JavaScript code.
To start the Node REPL, you just have to launch the command, node, on the command-line.
What is the difference between process.nextTick and setImmediate functions?
At the program start, its callback is called before the event loop starts iterating over the event queue.
Therefore, theprocess.nextTickcallbackis always called before thesetImmediatecallback.
What are stubs?
Stubs are used when testing applications.
In Node, we use libraries like Sinon for this purpose.
Why is it a good practice to separate app and server in Express?
By separating app and server in Express, we can separate the API implementation from the online grid-related configuration.
This allows us to carry out API tests without performing connection calls.
This also guarantees faster test execution and better code coverage metrics.
To achieve this separation, you should declare API and server in separate files.
Here we use two files:app.jsandserver.js.
What are yarn and npm?
Why would you want to use yarn over npm?
npmis the default package manager distributed with Node.js.
With the help of npm, users can easily manage dependencies used in a project.
yarnis also a package manager that was released as an answer to some of npms shortcomings.
However, yarn relies on the npm registry to provide users access to packages.
Like I mentioned before, yarn provides better functionality over npm in some cases.
Unlike npm, it caches every package you download, so you dont have to redownload it whenever needed.
It also provides better security by verifying the integrity of packages using checksums.
Sign up for updates on everything related to programming, AI, and computer science in general.