Google News
NodeJS Interview Questions
Yes, Node.js would run on a multi-core system without any issue. But it is by default a single-threaded application, so it can’t completely utilize the multi-core system.
However, Node.js can facilitate deployment on multi-core systems where it does use the additional hardware. It packages with a Cluster module which is capable of starting multiple Node.js worker processes that will share the same port.
It’s an approach to connect the output of one stream to the input of another stream, thus creating a chain of multiple stream operations.
Exit codes in Node.js are a specific group of codes that finish off processes, which can include global objects as well. Some of the exit codes in Node.js are:
* Internal JavaScript Evaluation Failure
* Fatal Error
* Internal Exception handler Run-time failure
* Unused
* Uncaught fatal exception
When any Node.js project is in the stage of production, Node.js promotes the principle to use NODE_ENV variable to flag it. When the NODE-ENV is set to production, your application will perform at a speed 2 to 3 times faster than usual. The variable also improves judgment during the development phase of projects.
Punycode can be defined as an encoding syntax in Node.js which is helpful for converting the Unicode string of characters into ASCII. This is done as the hostnames can only comprehend ASCII codes and not Unicode. While it was bundled up within the default package in recent versions, you can use it in the previous version using the following code:
punycode = require(‘punycode’);
In Node.js, spawn () launches a new process with the available set of commands. This doesn’t generate a new V8 instance only a single copy of the node module is active on the processor. This method can be used when your child process returns a large amount of data to the node.
On the other hand, fork () is a particular case of spawn () which generates a new V8 engines instance. Through this method, multiple workers run on a single node code base for multiple tasks.
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.
Tracing is a methodology used to collect all of the tracing information that gets generated by V8, the node core, and the userspace code. All of these are dumped into a log file and are very useful to validate and check the integrity of the information being passed.
readFile : This is used to read all of the contents of a given file in an asynchronous manner. All of the content will be read into the memory before users can access it.

create ReadStream : This is used to break up the field into smaller chunks and then read it. The default chunk size is 64 KB, and this can be changed as per requirement.
The crypto module in Node.js is used to provide users with cryptographic functionalities. This provides them with a large number of wrappers to perform various operations such as cipher, decipher, signing, and hashing operations.